12/19/2014 - No Comments!

Learning Git

github basics

I've been learning a new skill over the last few weeks, Git. A new project at work has given me the responsibility to write and maintain a Style Guide for our main web application project. This, along with some freelance projects I'm working on, have made this new skill a very necessary one for me to pick up, as I'm working remotely with multiple teams on shared codebases. Here, I'm posting my initial notes and new concepts I've picked up while learning Git. Connect with me on GitHub @ll_coolray.

Basics of GitHub

Git Status

  • Shows the status of your current repository.
  • It's a healthy habit to run git status often as sometimes things change without you noticing.
  • New files will show up as untracked in red.
  • To tell Git to start tracking any new files, you need to add it to the staging area by using git add.


  • Running git status will show the changes that need to be committed. These are local changes that have been made and are still in your staging area.
  • Here you can add or remove files from the stage before storing them (committing) in the repository.
  • This is the point where I usually need to delete my local .cache files generated by the local Sass compiler I use.
  • Run the git commit -m 'Your committee message here' command with a message describing what you have changed. Be as detailed as possible as you'll be wishing you had been when debugging at a future time.
  • You can use a wildcard to add or remove all files of the same type. For example, to add all .txt extension files, run git add '*.txt'.
  • Or, you can add everything in the current directory at once by running a git add -A command.


  • You can view the history of your commits by running a git log command.
  • Use git log —summary to see more information for each commit.
  • This will include the details of where new files were added or deleted and is a better overview of what's going on in the project.


  • The push command tells Git where to put your commits when you’re ready.
  • The default local branch name is master.
  • By adding -u to your initial push command, you're telling Git to remember the parameters for next time. For example, git push -u origin master' will tell all followinggit push` commands to push to the origin master branch.


  • If others are working on your code, it's a good idea to pull the latest before you do any new work. This helps to avoid potential merge conflicts.
  • You can check changes in and pull down the latest codebase on your GitHub repo by running git pull origin master.


  • When developers are working on a feature or bug they'll often create a copy (aka. branch) of their code that they can make separate commits to.
  • Then when they're done they can merge this branch back into their main master branch.
  • Branches are what naturally happens when you want to work on multiple features at the same time. You wouldn't want to end up with a master branch which has Feature A half done and Feature B half done. Rather you'd separate the code base into two "snapshots" (branches) and work on and commit to them separately.
  • Typing git branch reveals your current local branches.
  • You can switch branches using git checkout branch_name.


  • Checkout the master branch, then use git merge branch_name to merge your branch back with the master branch.
  • With it you can delete old branches by using git branch -d branch_name.

Git Basics Glossary

  • Directory. A folder used for storing multiple files.
  • Repository (repo). A directory where Git has been initialized to start version controlling your files.
  • Remote Repositories. A remote storage of your primary codebase smart to use remote repos for storage in case your local machine is lost.
  • Staged. Files that are ready to be committed.
  • Unstaged. Files with changes that have not been prepared to be committed.
  • Untracked. Files aren't tracked by Git yet. This usually indicated a newly created file.
  • Deleted. File has been deleted and is waiting to be removed from Git.
  • Staging Area. A place where we can group files together before we commit them to Git.
  • Commit. A snapshot of your repository. Used to create a nice, readable timeline of changes to a codebase over time.
  • Log. Think of git's log as a journal that remembers all the changes we've committed so far, in the order we committed them.
  • Origin. It's typical to name your main remote repository "origin", though it can be anything.
  • Git Stash. Sometimes when you go to pull you may have changes you don’t want to commit yet. You can stash these changes locally with git stash and then re-apply the changes after the pull with git stash apply.
  • HEAD. The head is a pointer which holds your position within all your different commits. by default, head points to your most recent commit, so it can be used as a quick way to reference that commit without having to look up the SHA.
  • SHA. Secure Hash Algorithm.

Published by: Ray in 2014, Learning, Presentation Notes