Musings of an 8-bit Vet

A Student Coders Tech Diary

Notes on a Github Rebase Workflow

This is primarily for my own reference, but it is an attempt to encapsulate the git workflow for working with repos being edited by other users.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
git remote add upstream "repo-path"     # set upstream to the correct place
git remote add remote_name git_repo_url # make alias for remote (co-workers) repo
  git remote -v                           # verify correct paths to repos

git fetch origin                        # check to see what changed
git rebase origin/branchname            # rewrite branch based on origin/branchname
git mergetool                           # run merge tool to resolve diffs
git rebase --continue                   # rebase not done yet!
  or git rebase --skip                    # if you want to accept changes
git clean -f                            # cleans up .orig files generated by merge

git status                              # always a good idea to check status
git add "file"                          # add only the file you changed!
git commit -m "message"
git push (-f)                           # -f forces changes if necessary
  git status                            # is working directory clean?

Setting the branch to track upstream: In order to track the remote branch on the first push from that branch specify the “-u” switch, i.e. git push -u origin repo_branch

Forking / cloning a repository: Make sure that you give your collaborator access to your repo from github.com under settings. You will add them by their github user name. If you don’t their git push will be rejected.

Error messages: Git is really good about telling you what went wrong, so read the error messages carefully.

Useful Resource: JohnWilliams.org: Git Command Essentials