chap 5 Flashcards
Create and move to new branch
git checkout -b alvin
or
git branch alvin // to create but not move to
Check what branch you are on
git branch
Move to a different branch
git checkout branch-name
Save and undo current changes
so you can move to a different branch for example
git stash –keep-index
This saves and undoes your outstanding, unstaged changes while preserving your stag‐ ed changes in the index, and resets your working tree to match the index.
Retrieve the stashed changes
git stash pop
Move to another branch and merge the current branch
git checkout thebranch -m
Delete a branch
git branch -d alvin
git branch -D alvin // Force deletion
rename branch
git branch -m old new
There is no direct way to rename the corresponding branch in a remote repository, however; you must separately push the new branch and delete the old one:
$ git push -u origin new
$ git push origin :old