# Git Workflow Cheatsheet
1. Create work branch
```
git fetch upstream
git checkout upstream/main -b my_branch
```
3. Hack on code
4. Add things to index
```
git add file_to_add
```
> Misko likes to use the UI to review and add indvidual changes to index
6. Commit index
```
git commit
```
> Let message open in IDE and edit it.
You can also do:
```
git commit --amend
```
8. Push to branch
```
git push origin
```
> you may want to use `--force-with-lease` (or `--force`)
9. Create a PR and get it approved
10. Merge PR from the Github UI use `Rebase` or `squash` workflow.
## Exceptions
1. Rebase on latest
```
# on your `my_branch`
git fetch upstream
git rebase upstream/main
```
This may result in conflicts you may need to resolve.
```
git rebase --continue
```
Safety:
```
git rebase --abort
```
2. Rearrange the list of commits
> First make sure you are rebased on latest see above
```
git rebase upstream/main -i
```
> `-i` means interactive and you will be able to say which SHAs to squash or update, etc... (Will have to use `git rebase --continue` and `--abort`)
## Check origin and upstream
```
git remote -v
```
---