Git

From RoboJackets Wiki
Jump to: navigation, search

Git is the Version control system used by RoboJackets for much of the code (we've moved some stuff over from SVN).

This guide is really short. To learn more about how Git works and how you can use it, see the Git website.

Also, here's an AWESOME Git tutorial: http://pcottle.github.io/learnGitBranching/.


RoboJackets now uses GitHub to manage git repositories and users.



Setup

  • Download Git
  • Each commit you make has your name and email address on it. Tell Git who you are with these are with these commands:


$ git config --global user.name "George P. Burdell"
$ git config --global user.email gburdell@gatech.edu


Commands

These are common commands that will get you started. There are more but you can discover those on your own. The commands are all shown from the command-line. There are graphical tools available but a good command-line understanding will help in using the graphical tools.

When using git through command line, first change your directory to the repository. So if your code is on your desktop in a folder called "repo", execute this command:

$ cd ~/desktop/repo



init

To start tracking an existing project with Git, cd to your project folder and use the init command. This sets up your project as a git repository.

$ cd ~/desktop/myproject
$ git init


clone

Use the clone command to make a copy of an existing repository.


$ git clone <remote-path>
$ git clone <remote-path> <local-path>


  • The remote path is the location of a directory on a Git server that has the files you want to check out. This will usually be given to you by the project lead or maintainer.
  • The local path is the location to store the files. If you don't specify a local path, Git will place create a new folder in the current directory with the same name as the copy on the server.

add

When you make changes in a repository that you'd like to commit, you must first add them to the "staging area". You can add changed files individually or add them all at once.

$ git add myFile.c
$ git add --all


commit

Once you add your changes to the "staging area" using the add command, you can commit them to your repository. Comment your commit so when others read it, they'll know what types of changes you made.

$ git commit -m 'Added new files to control the flux capacitor'


push

When you commit to your repository, they are added to the history only in your local repo. To add those changes to another repository, you use the push command.

$ git push <remote-repo> <branch>


  • Note: usually you'll be working on the master branch.

pull

If a remote repository has commits that you'd like to have in your repository, you can pull them.


$ git pull <remote-repo> <branch>