Pushing Changes to a Git Repository: A Simple Guide
Learn how to push your local changes to a remote Git repository, making them accessible to other team members. This guide will explain the push operation and provide step-by-step instructions.
Git - Push Operation
After modifying his last commit using the amend operation, tom is now ready to push his changes to the remote repository. The push operation permanently stores data in the Git repository, making tom's changes visible to other developers.
Viewing Commit Details
To verify the details of his latest commit, tom executes the git log
command:
Syntax
[tom@CentOS project]$ git log
Output
commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: tom Mouse <tom@tutorialsarena.com>
Date: Wed Sep 11 08:05:26 2013 +0530
Changed return type of my_strlen to size_t
Before pushing the changes, tom wants to review them, so he uses the git show
command:
Reviewing Changes with Git Show
[tom@CentOS project]$ git show d1e19d316224cddc437e3ed34ec3c931ad803958
Output
commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: tom Mouse <tom@tutorialsarena.com>
Date: Wed Sep 11 08:05:26 2013 +0530
Changed return type of my_strlen to size_t
diff --git a/string.c b/string.c
new file mode 100644
index 0000000..7da2992
--- /dev/null
+++ b/string.c
@@ -0,0 +1,24 @@
+#include
+
+size_t my_strlen(char *s)
+
{
+
char *p = s;
+
+
while (*p)
+ ++p;
+ return (p -s );
+
}
+
+int main(void)
+
{
+ int i;
+ char *s[] =
{
+ "Git tutorials",
+ "Tutorials Point"
+
};
+
+
+
for (i = 0; i < 2; ++i)
printf("string length of %s = %lu\n", s[i], my_strlen(s[i]));
+
+
return 0;
+
}
After confirming that he is happy with his changes, tom executes the push command:
Pushing Changes to the Repository
[tom@CentOS project]$ git push origin master
Output
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 517 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To gituser@git.server.com:project.git
19ae206..d1e19d3 master -> master
tom’s changes have been successfully pushed to the repository. Now, other developers can view his changes by performing a clone or update operation.