Skip to content

Git Workflow

Alison McCauley edited this page Jun 23, 2017 · 8 revisions

Remote Vs Local Repos

Setup

Naming up git remotes. Origin will decieve lie and betray you. You can't trust it.

  • When you start working with a repo do a git remote -v
  • if any of your remotes are origin then we insist on renaming.
  • Why? Because origin is always the first thing you clone from so it's ambiguous. We want to be precise and remove opportunity for confusion.
  • If your origin corresponds to your personal fork on github then do a git remote rename origin yourname
  • If your origin corresponds to the main project repository then do a git remote rename origin upstream

I want my local version of git to know about all the updates that have happened in all the other remotes

  • git remote update
  • note this command does not make any changes to you current branch or any other local branches.
  • This updates the records irrespective of your current branch.
  • Its like going to the library and getting and updated version of the card-catalogue. None of the books have changed but maybe there are new books(branches) or new issues of a magazine (ie commits)

I want to start a new branch

  • Start by getting the latest info from all the other remote repos git remote update.
  • Checkout a new branch starting from my upstream cannonical branch. git checkout -b my-new-awesome-branch upstream/master
  • If you don't do a git remote update here you will get a stale copy of the commit history.

How do I get my code onto github?

  • git push yourname

I need to get updates that are in the main or upstream master branch into my branch. Also known as rebasing!

  • git remote update
  • git rebase upstream/master
  • You may encounter merge conflict. Resolve them 1 by 1.

Pull request (PR) review

  • If reviewing PR 380, for example, go to the PR in GitHub -- in the right sidebar, add yourself as a Reviewer.
  • Then, get yourself set up for reviewing -- specifically, run the following:
    git remote update
    git pr upstream 380
    blt local:refresh
    cd docroot [if applicable]
    drush cim
  • Poke around / review / whatever...
  • Then, back on the PR in GitHub, at the top in a yellow box you'll see a green button to "Add your review" -- if you don't see it, you may need to refresh the page.
  • Aaaand, proceed however is appropriate for the circumstances :)

How the heck do I resolve a merge conflict

Interactive Rebasing: I need a Delorean so I can go back in time and fix a commit in my branch.

  • you can do this

I have a commit in my PR that I want to get rid of how do I?

How do I smash commits together

Other things (organize later...?)

  • If you aren't using the "OOTB" vm thing, you'll need to override the drush aliases -- but that's okay, copy drush/site-aliases/example.local.aliases.drushrc.php and put your overrides in the new file, local.aliases.drushrc.php.
  • origin == your fork
    upstream == source that you forked from
    • Because, you're not going to push your branches to the govcon repo, you're going to push them to your own fork, and then submit a PR :)
    • BUT, you do want to be able to grab things down FROM the govcon repo (thus, upstream).