- git fetch -p: git fetch prune removes remote tracking references that no longer exist on remote
- git branch -a: shows both local and remote branches
- git branch -r: shows remote branches
Haught git flow with interactive rebasing and squashing:
- switch to master, pull down, then check out your branch
git rebase master- fix any conflicts, then
git add .andgit rebase --continue git rebase -i <sha just before your 1st commit>- do the squashing!
git push origin [branch name] -f- don't switch to master and merge --> merge on Github via the PR
- viola!
Merge in master from your branch:
git stashgit rebase mastergit push -fgit stash pop
Example of how to set/change the upstream:
git remote set-url origin https://github.com/HaughtCodeworks/cfp-app.git
Some helpful git commands from Marty:
git config --global apply.whitespace nowarn ignore whitespace differences
git config --global core.excludesfile ~/.gitignore
git config --global push.default tracking
git config --global branch.autosetuprebase always default to rebase instead of merge on a git pull
Set a remote:
git remote add remote-name remote-url
Example: git remote add staging https://git.heroku.com/cfp-next-staging.git
Do a git fetch after
git blame - to see who did what in the terminal:
git blame [file path]
git fetch vs. git pull
fetch is safe and simply makes the local aware of changes
pull will try to merge or rebase (depending on what you have your local set to do)
Reset a file to its state before changes / the same state as if you just pulled from master (great for schema issues on master)
git checkout db/schema.rb