bio photo



What is Git?

  • Software for tracking changes in files
  • Helps coordinate distributed work for developers, released in 2005.

  • It’s open source and free and in it’s current form enables collaboration, revision management, debugging, CI/CD etc.

  • Before GIT became ubiquitous, SVN Apache Subversion or BitKeeper (paid) were used

Linus Trovolda

  • Creator of Linux, wrote Git

  • Linux is a Kernel written in 1991 - vast majority of webservers are Unix/Linux based

  • Key features led to high user adoption - free, stable, secure, multi-user (distributed)

  • Apparently he unplugged, went away in a cabin and didn’t leave until it was written, made it available for free

  • Here’s a (70 minute) talk he gave at Google (2007), about Git

Why is it called Git?

Over 40 acronmyms for GIT - all true

Linus says he likes to name things after himself (like Linux) - but the more likely explanation is git was sufficiently quirky and not a pre-existing Linux command (Estb. 2007)

  • leverage and added “social” elements to Git - a GUI, public + private + opensource code, a news feed, a graphical commit history
  • Github Pages (blog/personal websites), Github Gists (code snippet sharing)

  • word to the wise - they also have access to all your sourcecode, if you’re into privacy. MSFT paid ~$8 billion for a reason

Github Alternatives

Github w/ JIRA/Trello (Agile SDLC)

Git/Github Terms


  • Repository (repo) - root folder of application (code)
  • Remote Repo - hosted on a remote registry - aka upstream repo like GH, GitLab etc
  • Repo on your device (local repo aka locally)


  • multiple people can work on that code (engineers, QA etc)
  • git config --global "Mona Lisa"



  • Cluster of users
  • Let’s say Google Docs has one team of 8 developers and 16 QA engineers
  • We have an org. nyu-csci-ua-0467-001-fall-2021 the org has one repo each for the weeks HW, and org has each of you added as a team + user. Why? So you can potentially add other users into the team for collaboration (not required)


  • forum like place to commment/report on bugs/RFC (esp useful in opensource/public libraries/packages)

  • e.g. npm version x not compatible with new macOS update

Git locally, brew install git

  • if you’re on a mac and have brew, brew install git

  • else download it

  • check if it’s installed git --version

git version 2.21.0 (Apple Git-122.2)

git init

mkdir git-ws-test && cd git-ws-test
git init
ls -lah

git status

touch test.js
git status
  • Git becomes aware but doesn’t care - it’s not tracking changes in the file

git diff

  • you can add text into test.js but git wont track changes to it
git diff

echo 'hello world' > test.js

cat test.js

 hello world

git diff
#returns nothing

git diff test.js
#returns nothing

git add .

Until you run git add . or git add <filename>, and then make changes git won’t start tracking changes. Adding a file is also called staging (preparing) it for a commit

git add .
echo "you're added. am i being tracked?" >> test.js
cat test.js
git diff


  • You’re allowed to change your mind
use "git rm --cached <file>..." to unstage

git commit -m “this is a test commit (think of it as a tweet)”

  • You’re happy with the progress you’ve made, you want to commit to it - write a message

  • Some write essays in the messages - i prefer 144 characters or less (be clear + concise)

  • git commit -m "should be like a tweet"

git add . #the updated message
git commit -m "should be like a tweet"
  • git commit --amend

git push

  • Pushing repo without an upstream (remote) repo will give an error
git push

  fatal: No configured push destination.
  Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

  and then push using the remote name

    git push <name>

github create repo

git remote

git remote add origin
git remote -v

git user

git config --global "Mona Lisa"

git log

git log

  • Is a history of your commits (squash, cherry pick, reset)

git clone git pull

  • Sharing code is easy

git clone

  • once cloned - collaborator doesn’t need to git init, git remote add ... etc. s/he gets all the logs etc.
echo 'this is a collaborators input' >> test.js

git add .
git commit -m "collaborators input"
git push
  • Owner can now pull the change

git pull --rebase and they’ll have the updated test.js file

  • For this class, you don’t need --rebase just git pull would be fine


  • Git lets you branch out your code into separate streams (so different developers can work on it) and then merge or rebase back into the main/master branch. At this time you’re not going to need branches but here’s how you create/switch between them.
git branch
git checkout -b test_branch
git branch
git checkout master

git pull –rebase vs git pull (git fetch && git merge)

  • when working with others on the main/master branch a good strategy is to pull with rebase everytime you want to get some fresh stuff from upstream

git pull --rebase

  • Rebasing is the process of moving or combining a sequence of commits to a new base commit (git rewrites logs internally to make them clean/linear).

  • this avoids conflicts and re-pushing of code which happens under merge (git logs get crazy in merge)

  • Example of rebase - stackoverflow

  • Which strategy to use atlassian

  • Golden rule of Git rebase - never use it on public branches.

git stash

  • Sometimes - you’ll have local uncommited changes, but have to pull –rebase w. upstream.

  • Use git stash - it stashes your changes temporarily, clearing your branch for a conflict free pull --rebase, you can then git stash pop your changes back into branch OR git stash clear if the changes are redundant

vim .gitignore

  • tokens, keys, node_modules etc

Sample SDLC w. git

  • git is versatile enough for orgs to figure out their own workflow. Here’s a sample.

Cloning and working on last nights home work

git clone cd username-homework01 ls -lah

  • already has .git dir in it - you’re ready to make, add (track), commit & push changes

echo 'test text' > src/connectmoji.js git add . git commit -m "git ws test" git push

  • we can see your work
  • not the rest of the class
  • possible to add collaborators - but each of you are individually graded (check w. Prof Joe)