“Go on, Git!” Learning Git and GitHub

Jeremy Ying Tech Thoughts Leave a Comment

Git.  GitHub. Bash. Commit. Fork. Branch.

If you’ve dipped your toes in software development waters, you’ve heard these words before.  And last week I decided that it was time to stop being “curious” and just learn it.  Let’s talk about Git.

Git is a free, open-sourced version control application.  It’s a way for you to make changes to your latest coding or software development project, while allowing you to separate and properly manage the different versions that you cook up while you code away.

Me, when I first started learning about Git

Me, when I first started learning about Git

You install it onto your PC/Mac/Linus machine, then set up some initial files through the “Git Bash”.  And from that point onward, Git lets you track, manage, and record every change that is to your coding project.  It has no GUI (*gasp*), it isn’t intuitive, nor is it particularly easy to learn.  But holy heck- I can see how it’ll be useful.

Git is good for:

  • Tracking edits in text documents (as in, regular .txt files)
  • Sharing changes with other people who’re working on the same project

Git is not good for:

  • Images, movies, music, or fonts
  • Word processing files (like .docx files), spreadsheets, PDFs, PSDs, or any similar files which need to be reinterpreted by an application like Adobe Illustrator, or Microsoft Office.  Git would know that changes were made, but it’d have no idea what those changes were

Git tracks changes, not versions.  And all of your changes get moved into something called a “Repository” (Repo).  Different users can maintain their own repos, which contains your Commits (ie. changes that you finalize and make to your code).  If you want, you can help someone else work on their project by “Forking” it, which means you break away from their Repo, and do your own thing.

GitHub, on the other hand, is a web-based Git repository hosting service that allows you to put your Repos online, and work on other open projects that interest you.  GitHub isn’t the only hub service for this, but it is the most popular one.  It’s free if you’re okay with keeping your project open to the public, otherwise a privatized repo will cost you.

Me, after learning the Git basics and practicing with my own test Repositories

Me, after learning the Git basics and practicing with my own test Repositories

I learned the basics of using Git, but admittedly still need practice.  So if you’re like me and starting up with Git for the very first time, I’ve put together all of my Bash commands and notes just in case they might help you.  Otherwise, find me on GitHub! 🙂


In System:
git config –system

At User Level:
git config –global

Project level:
git config

To configure user name at User level:
git config –global user.name “Jeremy Ying”

To configure email:
git config –global user.email “jying4@gmail.com”

To see the configs you have set:
git config –list

To declare default text editor:
git config –global core.editor “notepad.exe -wl1”
‘wl1’ tells text editor to wait until you’re done, then start at Line 1.

To get Git Ui to colour output text:
git config –global color.ui true

To get into default user “root” directory:
cd ~

The Git equivalent of “dir” to list directories

The Git equivalent of “dir” to list directories AND hidden files:
ls -la

To list all Git files in a folder that has been Git initializeD:
ls -la .git

To view the Config file:
cat .gitconfig

To view Git Help file:
git help

For help on a specific command:
git help <command>

To change to Desktop:
cd Desktop/

To initialize a repo once inside desired directory:
git init

To tell Git to add all changes made to entire directory to Staging Index:
git add .

OR To tell Git to add all changes made to a specific file to Staging Index:
git add [file.txt]

Tell Git to commit all changes into repo (its memory) with a message:
git commit -m “Initial Commit”

To view commit log descriptions:
git log

To view commit log and set maximum number of Commits to return to you to one:
git log -n 1
or for two:
git log -n 2

To view commit log as of specified date (YYY-MM-DD)
git log –since=2012-06-15
git log –until=2012-06-14

To view commit log for specific author
git log –author=”Jeremy”

To view commit log for specific word string (example given: “Init”)
git log –grep=”Init”

To show changes made and report back the difference between the Working Directory, Staging Index, and Repository:
git status

To review changes made to Working Directory BEFORE committing:
git diff
git diff (filename)

To review changes made to Staging Index BEFORE committing (this compares Staging Index to Repository)
git diff –staged

To delete a file + add it to staging:
git rm (filename.txt)

To rename a file:
git mv (current filename.txt) (new filename.txt)

To move a file:
git mv (filename.txt) (destination folder name)/(filename.txt)
Can move and rename on same command, too!

To set up a remote repo:
git init in directory
git remote
git remote add <alias for remote’s name> <url of remote>. It’s in the Git Repo initial setup!

To push an existing repo, add your initial files, then do your first commit!
git commit -m “Initial commit”

git push -u origin master

To find fetch and push URL:
git remote -v

To delete a remote:
git remote rm origin

To see if remote is in your config file:
cat .git/config



Leave a Reply

Your email address will not be published. Required fields are marked *