Git 简明教程

Git - Push Operation

Jerry 使用 amend 操作修改了他的最后提交,并且他准备推送更改。推送操作将数据永久存储到 Git 存储库中。在推送操作成功后,其他开发人员可以看到 Jerry 的更改。

Jerry modified his last commit by using the amend operation and he is ready to push the changes. The Push operation stores data permanently to the Git repository. After a successful push operation, other developers can see Jerry’s changes.

他执行 git log 命令以查看提交详细信息。

He executes the git log command to view the commit details.

[jerry@CentOS project]$ git log

上述命令将生成以下结果:

The above command will produce the following result:

commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 08:05:26 2013 +0530

Changed return type of my_strlen to size_t

在推送操作之前,他想要查看他的更改,因此他使用 git show 命令来查看他的更改。

Before push operation, he wants to review his changes, so he uses the git show command to review his changes.

[jerry@CentOS project]$ git show d1e19d316224cddc437e3ed34ec3c931ad803958

上述命令将生成以下结果:

The above command will produce the following result:

commit d1e19d316224cddc437e3ed34ec3c931ad803958
Author: Jerry Mouse <jerry@tutorialspoint.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 <stdio.h>
+
+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 lenght of %s = %lu\n", s[i], my_strlen(s[i]));
   +
   +
   return 0;
   +
}

Jerry 对他的更改很满意,并且他准备推送他的更改。

Jerry is happy with his changes and he is ready to push his changes.

[jerry@CentOS project]$ git push origin master

上述命令将生成以下结果:

The above command will produce the following result:

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

Jerry 的更改已被成功推送到存储库;现在其他开发人员可以通过执行克隆或更新操作查看他的更改。

Jerry’s changes have been successfully pushed to the repository; now other developers can view his changes by performing clone or update operation.