Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Push clarification - What gets pushed?

Tags:

git

git-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?

like image 831
WinWin Avatar asked Jul 07 '11 13:07

WinWin


People also ask

Which tags are pushed with git push?

git push <remote> --tags will push both lightweight and annotated tags. There is currently no option to push only lightweight tags, but if you use git push <remote> --follow-tags only annotated tags will be pushed to the remote.

Does git push push everything?

No, git push only pushes commits from current local branch to remote branch that you specified in command.

What happens when you push in git?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.

Are git tags automatically pushed?

Now, getting down tags happens automatically when we call git fetch. If someone else has shared tags to the remote repository, git fetch automatically retrieves those shared tags. But it doesn't push them up, unless you are explicit about it.


1 Answers

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.
like image 140
che Avatar answered Sep 24 '22 21:09

che