What's the difference between "git push origin HEAD: clean_up" and no HEAD?
HEAD
points to the last commit of the current branch. So, if the current branch is clean_up
, I would expect the following two commands to do the same:
git push origin HEAD:clean_up
git push origin clean_up
I can think of a scenario where you can use something other than HEAD
when running git push
. Let's say you checked out a specific branch branch
in the state HEAD
. You've made a few commits to this, and now you've decided that you want to pull it into the repository as your new branch. However, you want to pull the branch from one commit before the last commit. In this case, you must follow these steps:
git checkout <SHA-1 of `branch` you want>
# make a few commits
git push origin HEAD~1:new_branch
This will push branch
to the remote before and re-enable the previous commit you made.
source to share