Quantcast
Channel: Version Control – PHP Developer
Viewing all articles
Browse latest Browse all 20

Moving unstaged changes to another branch in Git

$
0
0

If you move around between different branches a lot in Git, you might find that you accidentally make some changes on the wrong branch and only realise this when it comes to stage/commit them. As always, Git has a solution.

Assuming you haven’t staged any changes (using git add), the following three commands will switch everything to a new branch:


git stash
git checkout correct-branch
git stash pop

Viewing all articles
Browse latest Browse all 20

Latest Images

Trending Articles



Latest Images