Python logix
Python logix

Reputation: 359

how to push change in other branch which already commit on other branch

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

Answers (1)

Arora20
Arora20

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 -

  1. 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

  2. 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
    
  3. Then commit your changes.

Upvotes: 1

Related Questions