Configuring Git - northern-bites/nbites GitHub Wiki

Git is a version-control and software-management system. It is an extremely useful tool for keeping track of changes to code over time, especially when you have many people working on one code base. In order to get the Northern Bites' code, you first need to get git. See this page for info about setting up. NBites-specific instructions follow.

1. Make sure git is installed.

$> sudo apt-get install git-core git-gui git-doc

2. Create a GitHub account.

Go to GitHub and create an account (it's free!). If you're here, you probably already did this, seeing as this wiki is part of GitHub. Your username should be the same as your Bowdoin username, for simplicity's sake. Make sure to keep track of the email address you used to create this account, as it will be used later on when you're setting up your computer.

3. Add your ssh-key.

There are very clear instructions here; see Set Up SSH Keys. If this doesn't work, you should also add the private key, which they don't tell you in the guide.

4. Let team captains know about your Github account.

We need to add you to the list of contributors on the Northern Bites Github repository. You won't be able to share any changes to the code if we don't know about your Github account.

5. Download the code.

Navigate to where you want our code to live on your machine. We recommend your home directory. To get to your home directory, open a terminal and use the command:

$> cd ~

Then run the following line in the terminal:

$> git clone [email protected]:northern-bites/nbites.git nbites

6. Set your user options.

Set your name:

$> git config --global user.name "Robot C. Ball"

Set your email. Make sure the email address you use is the same one you set up your Github account with so that Github knows who makes these commits.

$> git config --global user.email "[email protected]"

Git will attach your information to your commits, so be sure your set this info, or you will confuse people as to who it doing what work.

If you are working on someone else's user name, or on a shared account, you will not want to set these globally. If you leave off the '--global' option, you can sent these values for each individual git repository, thus enabling multiple people to maintain separate repositories on the same computer. Keep in mind that we would like to maintain accountability for all code changes, less for blaming people when something goes wrong than for being able to find out who to talk to about a problem.


You've configured Git at this point, but there are some additional setup steps you can take. Note that the steps below might be outdated or OS-specific.

7. Make Git aliases in the terminal. (Optional)

These will provide shorter names for common git commands. For example git branch would be git br if you run the following commands:

git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.st status

Feel free to make the aliases whatever makes the most sense to you.

8. Other useful tweaks (Optional)

If you prefer to use emacs instead of vi (the default editor), run:

$> git config --global core.editor "emacs -nw"

On Linux, this sets the editor to be emacs (on the command line). Remove the -nw to pop up a GUI.

Colorize git:

$> git config --global color.status auto

On mac OS X, to be able to tab complete names of branches, remotes, and other names in git, download this file and rename it (use the 'mv' command in the terminal) to ~/.git-completion.sh Then, add this line to your .bash_rc, .profile, .bash_profile, or equivalent:

source .git-completion.sh

Git branch in the prompt

Check out this gist. This will colorize your prompt and put the current git branch in the prompt if you're in a git repository. See this if you're interested in changing the colors.

Have to login every time you push?

You can run:

git config credential.helper store

git push origin

Then enter your username and password to finish the setup!

You should now be good to go! Using git is a learning process, so see our Learning Git for help.

Head back to Linux Setup once you're done!