Thursday, September 25, 2014

Push to a Different Branch

Problem

I made updates to files, added them to the local git repo and committed them to the index (git's local staging repo).

Then I realized that I had failed to create a new branch.

So the files I just updated are in an old branch.

How do I move these files to a new branch on the remote repo in one command?

Solution

Use one of my handy git aliases, of course!

$ git push-current-branch-to-another <CURRENT_OLD_BRANCH_NAME> <NEW_BRANCH_NAME>


References

http://lexsheehan.blogspot.com/2014/06/handy-git-aliases.html
http://stackoverflow.com/questions/8550586/how-to-push-from-one-branch-to-another-and-checkout

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

1 comment: