Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 3.71 KB

Git 101.md

File metadata and controls

51 lines (42 loc) · 3.71 KB

Git 101

aka Git for Dummies

Assumptions

  • You already have git installed as a command line tool
  • You already have your git config set up with your identity

Setting up your Repository

  1. Go to https://github.com/ACEmulator/ACE, log in, and click fork. Next, grab the URL for your fork. It should be something like this: https://github.com/YourGitName/ACE
  2. Open your command line tool of choice, and make sure "git" is in your path. You can verify this by typing "git --version".
  3. Change into a directory you want to use as the parent folder to your codebase. For example, "c:\dev".
  4. Clone your repository/fork of ACE. To do this, type

You should now have an "ACE" folder in your current directory, and all the source should be downloaded. To get the project started, go back to the Readme.md for more information.

Starting Work

Any time you want to do work on ACE, you need to work in a separate branch. Here is the basic command:

  • git checkout -b branch-name-with-no-spaces-that-describes-your-changes origin/master

Let's break this down. "Checkout" is the command used to switch branches. But you have to create a new one! Well, that's what the "-b" does, followed by the name. The "origin/master" tells git what the source branch is. In this case, you're telling it to use your fork of ACE on github.

If for some reason, you already have saved, but uncommitted, changes in your master branch, you can do a "git stash" before you do the checkout (the checkout will probably have failed). After the checkout, do a "git stash pop" to pull your changes into your new branch.

Getting the latest code base.

This is pretty straightforward, but here's the git commands to do it:

Creating a Pull Request

So, you've got something you want to add? Great! This is a team effort - thanks for helping out. After you have all your changes working locally, here's how you get that code to us.

  1. "Stage" all your changes. This is basically telling git what all files are changed. 99% of the time, it's everything you've changed. At the command line in the ACE folder, type
  • git add .
  1. Commit your changes. This creates a changeset that is what will eventually become your pull request.
  • git commit -m 'your message without single quotes here'
  1. Push your changes up to github.
  • git push origin your-branch-name-here
  1. Go to https://github.com/ACEmulator/ACE, pull request tab, and hit the big green "New pull request" button. Find the "compare across forks" link in the upper right. Find your fork and branch in the drop downs below, add in whatever comments are appropriate, and click the green "Create pull request" button.

Rebasing

Oh the dreaded rebase. Sometimes you'll get hit with a "Merge conflict" change in your pull request. You need to rebase. If you did all the setup above, you're in good shape.

  1. Commit any uncommited work. See steps 1 and 2 of "Creating a Pull Request" above.
  2. Get the latest stuff from the head ACEmulator master branch as above.
  3. Rebase your branch
  • git checkout your-branch-name
  • git pull --rebase
  1. Resolve merge conflicts, if any. Using Visual Studio is the best way to do this. Your git command prompt will tell you if you have any conflicts, and you may be prompted to resolve them multiple times. After each time in Visual Studio, return to the command prompt and type "git rebase --continue" after you've resolved the conflicts.
  2. Rebuild, retest, etc.
  3. Commit any uncommitted changes (there should be some if there was anything to rebase at all).
  4. Push up to github. If you already had an open PR on that branch, it will be updated automatically.