Dileep Domakonda
Dileep Domakonda

Reputation: 19

Git copy changes from one branch to another without committing the changes in source branch

I am new to git. I have a branch named BranchA from the master. I have some changes in BranchA (I am not going to merge changes from BranchA to master). Now I have created another branch from the master named BranchB. I want the changes from BranchA to BranchB. Here, I don't want to commit the changes in BranchA. And changes in the BranchA(which are copied to BranchB) should get deleted.

Upvotes: 1

Views: 53

Answers (2)

Mike
Mike

Reputation: 1343

Make sure the changes you have is uncommited and unstaged. Then you can use git stash:

git stash

Then move to your Branch B and then:

git stash apply

Upvotes: 2

Bibek
Bibek

Reputation: 784

If you want to include the new changes from BranchA to BranchB then first commit and push on Branch A but if you don't want to commit the changes then first discard the current changes. Then switch to new branch usind git checkout BranchB then try pulling branch git pull origin BranchA

Upvotes: 0

Related Questions