开发者

Git Push clarification - What gets pushed?

开发者 https://www.devze.com 2023-03-17 19:08 出处:网络
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?

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 oth开发者_Python百科er 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?


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.


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.


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消