Skip to content

Instantly share code, notes, and snippets.

@roubaobaozi
Last active September 16, 2018 13:08
Show Gist options
  • Save roubaobaozi/d9e8f6fd9d04ffbf95d1f9333aa71337 to your computer and use it in GitHub Desktop.
Save roubaobaozi/d9e8f6fd9d04ffbf95d1f9333aa71337 to your computer and use it in GitHub Desktop.
version control strategy for Navid

Version control strategy

Recommendation

  1. Repo #1: contains the central functions, subject to gitflow branching methodology or with a repo gatekeeper.
  2. Repo #2: separate trees of work. Each user has one branch that will be their develop, eg. develop-navid, develop-otherperson etc. Off those branches, each user creates their feature branches (twigs, eg. feature/navid-work-part-one.) Squash feature branches to a single commit before merging back into their own develop-navid or whoever, to keep commit histories clean. Into separate folders, clone that fastai by version (this will keep local copies by version in your own repo, making it much larger, but at least you can keep separate versions of the code for your old and new notebook things.)

Read about gitflow here: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Get me the freshest code

  1. git fetch
  2. git reset --hard origin/<myBranchName>

This is the safest way to avoid local-origin disparity. It will nuke your local code and always get freshest origin. Assume origin is good; it should be.

Squashing for clean commit histories

  1. git rebase -i HEAD~<numberOfCommitsToSquash>
  2. Follow the key to f (squash and discard commit message) or r (amend commit message) etc. so you can squash multiple commits in your twig, to merge one clean commit into your branch.

Picking code

  1. If you want to grab someone else’s latest changes to a file, git checkout feature/otherperson-branch -- filename.ext or git checkout develop-otherperson -- filename.ext
  2. If you want to grab an entire commit of someone else’s, git cherry-pick <commitNumber>

I made a mistake

Locally

git reset HEAD~ will un-commit, and you can make your changes, re-add, and then commit again

Already pushed to origin

The proper way

  1. Make a new twig git checkout -b feature/navid-revert
  2. git revert -m 1 <commitNumber> which is the commitNumber of the merge
  3. Make a PR (Peer Review) of this and merge it into your develop
  4. Make a new twig git checkout -b feature/navid-revert-the-revert
  5. git revert -m 1 <commitNumber of the revert>
  6. Make necessary fixes, make a PR, and merge it into your develop

The not-proper-way (don’t do this if you are sharing code please. Fine if you’re working on code that’s purely just you touching it)

  1. git reset HEAD~ to un-commit
  2. Make necessary fixes, commit and git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment