WinWin
WinWin

Reputation: 7753

Git Push clarification - What gets 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 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?

Upvotes: 6

Views: 443

Answers (3)

che
che

Reputation: 12273

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.

Upvotes: 7

VonC
VonC

Reputation: 1328972

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.

Upvotes: 3

Abizern
Abizern

Reputation: 150735

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.

Upvotes: 3

Related Questions