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.
- 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 email@example.com
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
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
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.
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
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'
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.
If a remote repository has commits that you'd like to have in your repository, you can pull them.
$ git pull <remote-repo> <branch>
To unstage files that are currently staged, you can use the reset command. Leave the filename parameter empty to unstage all files
$ git reset <filename>
You can also choose to undo all uncommitted changes, resetting your repository state to the most recent commit, or a commit that you specify. Be careful with this, as this cannot be undone.
$ git reset --hard <commit-hash>