Created
June 17, 2013 18:43
-
-
Save niksumeiko/5799210 to your computer and use it in GitHub Desktop.
Use 'git stash [, pop]' to commit to the proper GIT branch when discovered that you have made local changes in an inappropriate branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sometimes we discover that local changes we have made in our GIT project | |
# are not related to the branch we currently work in. | |
# So we need to switch the propoer branch before committing the changes. | |
# 'git stash [, pop]' is going to solve the problem easily. | |
# 1. While you have uncommitted changes, 'stash' them to create a temporary | |
# commit of the current state of the working copy (both cached and | |
# uncached files) and to revert the working copy to the current HEAD: | |
git stash | |
# 2. Switch to the proper branch: | |
git checkout PROPER_BRANCH | |
# 3. Now when in proper branch, take previosly stashed changes with 'pop', | |
# what is going to stash these changes and remove stashed commit from | |
# the "stash stack", applying the commit to your current branch: | |
git stash pop | |
# You'll notice automatic merge if there are conflicts between 2 branches. | |
# If there's a conflict that was not able to be merged automatically, | |
# process manually with your compare editor. | |
# 4. Done! You're allowed to commit your changes to the proper branch now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment