Link Search Menu Expand Document

Version Control (Git)

Version control (sometimes called source control) is a general term for how you keep track of changes to the code of a project. You may have practiced some form of version control in the past by saving out the latest working version of a program and appending “_works” to the end of the filename so that you can fall back on it just in case. Also, you might have had to work with a team on a project, and had to mark each version from each different team member with their initials, and then manually merge all of the code together into one working program (hopefully).

Developers got fed up with having to manually handle version control, so they started creating tools that would make the process easier. In the case of CDL, we use a system called Git. This system:

  • Keeps track of every change made to every file, including adding and deleting files.
  • Allows for remote storage of code (called a repository) on our GitLab server.
  • Automatically merges code submitted from multiple developers.
  • Facilitates “branching” off the codebase into multiple concurrent versions.
  • And much more…

Getting Familiar with Git

You will need to sign into LinkedIn Learning with your NID and NID password to get access to the courses in this training.

  1. Make sure to complete the instructions on the Install Homebrew and Git page.

  2. Complete the Git tutorial on LinkedIn Learning.  Use the Homebrew installation option.
  3. View these two YouTube videos:
  4. Read about the Gitflow Workflow.  Don’t use the git-flow extension.
  5. Set up your local Git options and ignore rules with recommendations from this Gist.

Local Git configuration

So you’ve installed git on your computer, which is great! Now we need to configure it just right.

Some good practices to consider before setting up your local settings.

  • You want to use your real name when configuring Git. You will be working a lot with git, and you wouldn’t want all credit to your works to go to ‘coolTurtle22’.
  • Use an email you are comfortable sharing in a professional setting, as well as one you’ll use on the regular. You don’t want to create a github solely for work if you already have one you’re accustomed to.

Now let’s pretend your name is Tate Taters!
Setting up your name and email for work would look similar to this:

Global command for the username

git config --global user.name "Tate Taters"

Global command for your username

git config --global user.email "Tate.Taters@ucf.edu"

If you don’t know your work email, it should be listed in the ‘Contact Information’ section of your profile page, on Workday. Note: To check that you correctly assigned the values, you can use git config followed by user.name or user.email.

This information is configured globally with the --global attribute, and thus becomes the ‘default’ for any git repository in your workstation.

Having done this, you may want to configure other components of your git globally. For this, you can use the command git config --global --list. These settings are saved in ~/.gitconfig. Feel free to check it out to see what configurations you already have set up. To read up on more available options, visit the git config site!

Global Git Ignore

A very important piece of every git repository is its gitignore. This tells the repo what files to ignore when you are making changes and pushing them to Github/Gitlab. Therefore, any changes to a file listed in the gitignore will not show up when you use the commands git status and git add. Making them appear will require a force flag (-f or --force) or the removal of said files from the gitignore.

The gitignore is excellent at keeping files untracked when they contribute nothing to the repository or expose sensitive information. This simplifies development and grants you piece of mind (and an emptier screen) when you use the commands git status and git add.

A good practice is to have a global gitignore to prevent general tedious files to make it through to the commit. We will show you how to set one up!

  1. Create a global gitignore file in your home directory using touch ~/.gitignore.
  2. Copy the lines in the sample gitignore into the new file.
  3. Tell git to use the new ignore file via the git config --global core.excludesfile ~/.gitignore command.

Using this file, you’ll save yourself a looot of headaches! You may have one right now after reading all this, but I promise it’ll pass! :)

Additional useful commands

Make sure to check out this help guide to learn how to change the name of a new default repo, how to configure git to use a specific editor when committing a message, etc.

Of course, all of this effort is null if you can’t find yourself a repository to work on! This brings us to our next and final section about Git. I know, so sad it’s nearly over..

Updating your Github email

Last but not least, it’s important you can get access to Github and check some settings that will help you a ton!

  1. Log into Github with the account you will be using while at work (could be your personal one).
  2. On the top right corner of the page, you’ll see your profile icon. Click on it, then click ‘Settings’ .
  3. Go to ‘Emails’ .
  4. Make sure at least one of your emails is listed here so Github can reach out to you if you’re ever locked out!
  5. Consider using your work email as your primary email, seeing as it will be the only one receiving emails from Github.

You are now done configuring all you will need regarding your Git setup! Notify your trainer so they know you have made it past this intense Git journey!