Today, Greg Borenstein gave us an introduction to Git and Github – both amazing and necessary tools within the development world. My GitHub account can be found here. The Git workflow is as follows:
- Do work
- Save changes (commit)
- Share changes (push)
- Get changes (pull)
- Experiment (branch)
- See changes (diff)
- Combine changes (merge)
- Undo changes (revert)
General commands that are important to know are:
pwd #where you are
cd #move to file directory
open . #opens in finder
mkdir #create a folder
ls #list content within the folder you’re looking at
man [command] #view manual of a specified commans (ex. man ls)
:q #quit if you’re in edit mode
ls -la #show hidden files
which git #shows where git is installed on your machine
open .git/config #opens git config file in that folder
Now onto the interesting stuff. How do you create a git repository, add, commit, and save locally:
git init #make git repository in current location
git status #show status of modifications
git add . #add everything in this folder to be commited
git commit -m “[message]” #commit to repository – this will create a number called a sha
If you have changed the file since your last commit you can use the following to view the difference, commit or revert
git log #views repository logs for this folder
git diff [sha1]..[sha2] #shows what has changed within the file
git revert [sha] #reverts to specific repository date
git reset — hard #undos the last git commit
git checkout -b [name] #creates a name associated with updates
git checkout [name] #brings you to how the file last looked like with that associated name. This is good in order to toggle between two peoples updates
Lastly, we learned how to push and pull our Git to a GitHub repository:
First – got to your Github.com account and create new repository. This will give you the information needed to go to your terminal and do the following:
git remote add [git@github.com:[username]/[repositoryName].git] #links the folder you’re in to the github folder
git add .
git commit -m “note”
git push #pushes files to the repository
If you’re pulling someone elses repository down into a local file you would do the following:
git remote add [name] https://github.com/[name]/[repositoryName].git #add the remote directory
git pull [name] master #pulls the files from external account
git pull #this is to pull from your own account



