Git and Github for MNS


by Colin Flynn

What are Git and Github? Why would I use them?

Git and Github are a distributed version control system. It lets multiple developers work on the same codebase without ruining each other’s code (when used correctly). Github also acts as you code backup system and provides a tremendous level of detail so that you can almost “audit” the work that was done.

Using Github for Mac + Github CLI (Command line interface) - A hybrid approach

I have found that when teaching others about github, that using a mixed/hybrid approach of using the GUI and the CLI let’s people understand github the quickest.

  1. Create a github username at Github
  2. Download and install Github for Mac
  • Use Github for Mac GUI to add/create repos
  • Use the CLI for almost everything else
  • Check your progress with the GUI and on the Github webapp

Git and Github Nomenclature

  1. Repo/Repository - file folder (where you are storing your files)
  2. Commit - git commit -am "<commit message>" - saving/making changes on your machine
  3. Push - git push origin master - giving the changes back to the repo from your machine
  4. Pull - git pull origin master - getting the latest version of the repo into your local machine (a combination of fetch and merge)
  5. Fetch - getting the files
  6. Merge - combine commits if multiple people were working at the same time (will notify you if there is a merge conflict)
  7. Fork - make a copy of the repo and provide attribution back to author (or pull requests)
  8. Clone - git clone '<http://repourl.git>' <foldername> - make a copy of the repo onto your local machine
  9. Branch git checkout -b <branchname> - copies of the repository where specific features can be worked on with constantly dealing with merge-conflicts
  10. Stash - git stash - when you have made changes but you aren’t quite ready to commit them, you can ‘stash’ them, then pull the repo again, then stash apply
  11. Stash Apply - git stash apply - applying your stashed changes to the new code you just pulled
  12. Pull Request - Preferred method of contributing to open source projects that you are not a contributor to. This is done by first forking the repo, then submitting a pull request with descriptions of the changes. These are also used on small teams to signal a code review before merging with the master branch (matter of developer preference)
  13. Revert - Creates a new commit that reverses the code changes made by the code you are reverting
  14. Status - git status - Provides you with a current status of any file changes or additions that would need to be stashed, committed, or added before a push or pull
  15. Remote - git remote -v - Enables you to check what git repo your connected to currently and the names of them (origin, remote, heroku, etc)

Origin vs. Remote Repositories

When you are making commits you are working on your own github repo (this is the origin)

When you deploy, you are changing a git repository that the hosting provider has (this is the remote [or you can call it heroku or modulus or whatever])

Hosting providers = heroku, modulus, etc.

Committing and pushing changes

git pull origin master
git status
git commit -am “describe changes made”
git push origin master

Committing and pushing when you’ve added a new file

git pull origin master
git add .
git status
git commit -am “new file”
git push origin master

Cloning something (specifically meteor boilerplate)

git clone https://github.com/Differential/meteor-boilerplate.git mns-boilerplate
cd mns-boilerplate
rm -rf .git

Special Thanks to Melissa for taking notes

Share Share on Twitter Share on Facebook Share on LinkedIn

How Can We Help?

Reaching out doesn’t mean you’re ready to start a project, but we’d love to learn more about the challenge you’re facing, answer any questions, and see if we might be a good fit for working together.

Contact Us