- Stash - saves your changed files off to a temporary shelf.
- Stash Pop - get those changes back and apply on top of current branch.
- Make sure your repo is in sync - Lesson 2
- Admin merge in PR to upstream - so that repo is ahead
-
Navigate to your repo if you're not already there
Set-Location C:\GitHub\GitDemo -
Check status to see where you are
git status -
If you're not still on the addFriends branch, check it out
git checkout addFriends -
Make a change
notepad .\README.md
-
Check status to see where you are
git statusOn branch addFriends Your branch is up to date with 'origin/addFriends'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a") -
Oh no - I'm still on the old branch - addFriends. Checkout master so we can create a new branch
git checkout masterPS C:\GitHub\GitDemo> git checkout master error: Your local changes to the following files would be overwritten by checkout: README.md Please commit your changes or stash them before you switch branches. AbortingThat didn't work as the checkout would overwrite my changes.
-
Stash the changes
git stash -
Now checkout master
git checkout master -
Update master from upstream
git pull upstream master -
Update your fork on Github (origin).
git push -
Create a branch for your new work
git checkout -b newIdea -
Un-stash your changes
git stash pop -
Now you've made your changes against the most up to date copy of the master branch.
-
Add, Commit and Push.