Reputation: 359
I have two branches master and version_one.
I was in master branch and I have added few files in git and commited on master but I want to pust it on version_one branch
Can I change checkout branch version_one and push that commit on version_one so that my changes are push on version_one branch only
git branch
master
git add file_name.txt
git commit -m "new change"
Upvotes: 0
Views: 53
Reputation: 1063
There are many ways you can do this. I am assuming that you already have version_branch in your local. One of the options which I follows is -
Checkout to the master branch. Revert the changes which you pushed to the master. You can do using
git reset HEAD~
By this you can see the changes under git status
Checkout to version branch. Before that, you need to stash the changes and apply the same stash after checkout.
git stash
git checkout version
git stash apply
Then commit your changes.
Upvotes: 1