Git Push 澄清 - 推送什么?

发布于 2024-11-18 16:30:19 字数 349 浏览 3 评论 0原文

当我推送本地工作目录到中央存储库,是否会推送所有中间分支和提交信息(从上次推送到本次推送)?

换句话说, push 是否会产生 <我当前工作目录的整个历史记录的精确副本,包括提交、分支等,因此可供从中央存储库提取的任何其他用户使用?

如果不是一切都被推动,那么什么会被排除?

When I push a local working directory to a central repository, do all intermediate branches and commit information (from last push to this one) get pushed?

In other words, does push produce an exact replica of the entire history of my current working directory, including commits, branches, etc., and thus are made available to any other user pulling from the central repository?

If not everything is pushed, what gets excluded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我三岁 2024-11-25 16:30:19

当您运行 git push 时,您可以设置在命令行上推送的内容。例如,这

git push origin my-branch:fooo

会将分支“my-branch”从本地存储库推送到“origin”处的分支“fooo”。

当您在不带任何参数的情况下运行 git push 时,它会推送到当前分支的远程集(您可以通过 git configbranch..remote 看到它)并且执行 push.default 配置值中配置的操作,根据 docs,可以是以下之一:

  • nothing - 不推送任何内容。
  • matching - 推送所有匹配的分支。所有两端具有相同名称的分支都被认为是匹配的。这是默认设置。
  • upstream - 将当前分支推送到其上游分支。
  • tracking - 已弃用的上游同义词。
  • current - 将当前分支推送到同名分支。

When you run git push, you can set what gets pushed on the command line. For example, this

git push origin my-branch:fooo

pushes branch "my-branch" from your local repository to branch "fooo" at "origin".

When you run git push without any arguments, it pushes to remote set for your current branch (you can see that by git config branch.<branchname>.remote) and does what is configured in push.default configuration value, which, according to docs, can be one of the following:

  • nothing - do not push anything.
  • matching - push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.
  • upstream - push the current branch to its upstream branch.
  • tracking - deprecated synonym for upstream.
  • current - push the current branch to a branch of the same name.
執念 2024-11-25 16:30:19

它推送您为该远程存储库配置的分支。查看配置文件 .git/config 以了解已配置的内容。

如果您想查看推送的内容,

git remote show origin

请使用将 origin 替换为远程存储库的名称。这显示了哪些分支将推送到该存储库,以及分支的当前状态是什么。

It pushes the branches that you have configured to for that remote repository. Have a look at the config file .git/config to see what has been configured.

If you want to see what will push use

git remote show origin

where you replace origin with the name of your remote repository. This shows what branches will push to that repo, and what the current state of the branches are.

翻了热茶 2024-11-25 16:30:19

要完成其他答案,请不要忘记 git push 通常处理分支 (refs/heads)。

  • 它不会推送标签,除非您指定 --tags (或 --mirror),在这种情况下 refs/tags 会被推送。
  • 不会推送笔记(经常被遗忘)除非您明确指定 ref 命名空间。

To complete the other answers, don't forget that git push usually deals with branches (refs/heads).

  • It won't push tags, unless you specify --tags (or --mirror), in which case refs/tags are pushed.
  • It won't push notes (often forgotten) unless you specify that ref namespace explicitly.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文