Skip to content

Instantly share code, notes, and snippets.

@zganger
Last active March 28, 2019 15:45
Show Gist options
  • Save zganger/b7063576f68f38d7c719cab45cf0f972 to your computer and use it in GitHub Desktop.
Save zganger/b7063576f68f38d7c719cab45cf0f972 to your computer and use it in GitHub Desktop.
A simple guide to using git with a fast-forward rebase workflow

Using Git with a fast-forward rebase workflow

General workflow:

  • To clone a repo: move to the desired diretory and git clone git@<host>:<organization>/<repository>.git
  • To view your current branch and changes: git status
  • To view commit history on current branch: git log
  • To get lastest code: git pull origin <branch_name> while in your repostory directory
  • To view all local branches: git branch
  • To create a branch: git checkout -b <branch_name> while in your repostory directory
  • To stage for commit: add changes using git add <file_name> <file_name_2> or git add -a :/ to take all changes
  • To commit: git commit -m '<add commit comment here>'
  • To push changes to your feature branch: git push origin <branch_name>
  • To switch branches: git checkout <branch_name> while in your repostory directory
  • To rebase a feature branch onto a target branch: pull latest on target, check out to feature branch then git rebase <target_branch>
  • In the event of conflicts: git mergetool -t meld, select the desired changes to the middle section, save, then push to your feature branch. Retry rebase.

After your branch has been merged:

  • To clean up your links to the remote repository: git remote prune origin
  • To delete local copies of old branches: git branch -D <branch_name>
  • To clean up trash: git gc --aggressive (this may take a while-- you don't need to run it often.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment