- Use `<group>/<description>` to describe your branches
- For example, a fix for a compiler issue should have a branch name of `fix/description-of-compiler-issue`
- Note that the branch should be descriptive but not too long (i.e. don't make it longer than above, since the example above is pretty long already)
- Always create a new branch when submitting pull requests. This allows you to create multiple pull requests for different issues, prevent conflicts between your master branch and upstream, as well as some other things.
If you haven't already, make sure that you have added a remote to the original (upstream) repository: `git remote add upstream <dir>`
1. Fetch all the branches of that remote into `upstream/<branch>`: `git fetch upstream`
2. Change to the branch that you want to update (usually master): `git checkout master`
3. Rewrite that branch (usually master) with the changes upstream: `git rebase upstream/master`
If a lot of people have forked your reposiory, then it may be better to use `git merge upstream/master` instead. This avoids rewriting history, but at the cost of clean pull requests.
It may be necessary to force push your changes with `git push -f origin <branch>` (usually master).
- Search for a string in the files of a git repository: `git grep <pattern>`**OR**`gg <pattern>`
- Search for any tab characters in a repository: `git grep $'\t'`**OR**`ggt`
- Search for any carriage returns in a repository: `git grep $'\r'`**OR**`ggr`
- Merge all unpushed commits into a single commit: `git rebase -i origin/master`
- Note that you are not done after this. You must also change `pick` to `squash` (or `s`) for all of the commits you want to merge. This is usually everything except your most recent commit.
- Another window will open to let you combine all the commit messages into one big commit message
- Merge the current branch with another one (usually master): `git merge <branch>`
- Change the remote location if your upstream repository URL changes: `git remote set-url origin git@address:user/repo.git`
- Get an idea of how much has changed since the last commit: `git diff --stat`
- Rebase the last N commits (i.e. edit them): `git rebase -i HEAD=N`
- Apply the commit as-is: `pick`
- Edit the commit message: `reword`
- Edit the file(s) and/or commit message: `edit`
- Merge the commit with the previous commit: `squash`
- Merge the commit with the previous commit and discard the commit message: `fixup`
**NOTE:** You should only merge commits with local commits that you haven't pushed yet. Doing this for upstream commits can cause problems for other people that have cloned your repository.