Get started with git version control

Follow along as I document my work, life and projects.

Chances are you have git already installed and you can check that by running git — version. If you don’t have git installed just hit brew install git in your terminal and you’re done.

Let’s configure git globally.

  1. Set up your username git config — global = ‘Ben Fisher’
  2. Set up your email address (obviously add in your correct email address)git config — global = ‘’
  3. Let’s initialise the project so we can add version control to the project. First make sure you are in your project root directory using the cd comand. Next run git init. This will add a .git folder to your directory
  4. Next I’m going to add the files I want to track by running git add .
  5. And I’m going to commit my initial commit by running git commit -m ‘initial commit’
  6. I use bitbucket but you can use github or gitlab as your main repository. First I’m going to add a new repository to bitbucket —
  7. Next you will be given some instructions on how you can link your local repository to your bitbucket repository and it will look something like this git remote add origin
  8. If you have a fresh environment like me you will need to first generate a public/private rsa key pair by running ssh-keygen -t rsa
  9. After the prompt to save the key just hit enter and enter passphrase or not to your preference
  10. Now we need to add the ssh keygen file by following these instructions —
  11. Also link up your bitbucket account and local repository. Instructions found here —
  12. You can now push to your bitbucket repository once the setup is complete git push -u origin master

The last few steps can be tempormental so don’t give up if you hit a few uncertainties. That’s just the nature of software development. Little tip, if you have to create the config file from scratch use vim to edit the file once it has been created with the touch command.

For future updates all you need to use (for now) is the following commands from your terminal:

  1. git status
  2. git add .
  3. git commit -m ‘name of your commit’
  4. git push -u origin master

If you ever need to test new code or install dependecies and roll back changes you can use:

  1. git reset HEAD — hard (removes any tracked changes that have not been committed)
  2. git clean -fd (cleans out anything not in the staging area)

Once git has been setup correctly and Atom restarted you will notice changes highlighted in your repository by Atom — for more information go here.

That’s it for today. Let me know if you have any tips or tricks to share with others.

Until next time!


Be Excellent