Skip to content

Instantly share code, notes, and snippets.

@progapandist
Last active August 22, 2017 10:51
Show Gist options
  • Select an option

  • Save progapandist/32418231dcc9990afe10cb84ae30ce10 to your computer and use it in GitHub Desktop.

Select an option

Save progapandist/32418231dcc9990afe10cb84ae30ce10 to your computer and use it in GitHub Desktop.

Rules

  1. No commits/pushes to master 🚫
  2. Every feature (or every fix, anything new from master) is a new branch
  3. Never re-use branches

Recommendations

  1. Commit often (every time you’re happy/your code working). Remember, commits are “saves” or “snapshots” of your local code, something for you to rollback to if something breaks and also to track your own progress!
  2. Don’t understimate the power of PR interface on Github. Describe your changes, read code, ask questions, ask for corrections before you merge!

GIT CHECKLIST

Ideal case

You finished working on the feature/branch, and there were no changes to remote master while you worked on it

T — terminal G — github.com

  1. T gst # is it green/red? if yes — 2
  2. T git add . && git commit -m "describe change in present tense" # e.g.: “change button position”
  3. T git push origin name-of-your-branch
  4. T hub browse to go to the GitHub web interface
  5. G You will notice a prompt asking you to create a Pull Request, use the prompt
  6. G Describe your changes and create Pull Request ⚠️ Don’t merge yourself unless 1000% sure
  7. G Lead programmer closes your PR (merges your changes to remote master). But you’re not done yet!
  8. T git co master # to get back to master
  9. T git pull origin master # to update your local master with remote changes
  10. T git sweep # to delete the branch you’re done with
  11. T  git co -b my-new-feature # because life is hard and you never stop working

More realistic case

You are not done working and you need changes from remote master to go on

  1. T gst # is it green/red? if yes — 2
  2. T git add . && git commit -m "an explanatory description in present tense"
  3. T git co master # to change to master
  4. T git pull origin master to get the master with all latest changes
  5. T git co your-current-branch-name to switch back to your branch
  6. T git merge master to merge remote changes to your current branch ⚠️ ⚠️ ⚠️ ACHTUNG! Conflicts!!!
  7. Relax 😌
  8. Resolve conflicts by going to all conflicted files and keeping just one good version of code (talk to other people here!). You may want to run rails db:migrate in your merging branch too (if you have a conflict in a schema).
  9. T git add . && git commit -m "resolve conflicts"
  10. Continue your work in a current branch until done.

When done: Follow the best-case scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment