Skip to content

Git and Git LFS

Kevin Siwoff edited this page Feb 12, 2018 · 8 revisions

Git is an incredibly powerful technology for maintaining revision history in text documents. We will use Git and Github extensively in this class. Git is not very good at maintaining large binary files such as MOV files, MP3s, etc. That's where Git LFS comes in:

About Git LFS: https://help.github.com/articles/about-git-large-file-storage/

Git LFS tutorial https://github.com/git-lfs/git-lfs/wiki/Tutorial

How to collaborate with others using git lfs: https://help.github.com/articles/collaboration-with-git-large-file-storage/

For Windows users

The simplest way to work with git/github on Windows is through the Github Desktop client. You can download Github Dekstop here: https://desktop.github.com/

Unfortunately, git lfs doesn't work out of the box with the Github Desktop client. To enable it on a repository,

  1. Make sure you've downloaded Git LFS here: https://git-lfs.github.com/
  2. After downloading and extracting installer, Open Github Desktop --> Repository --> Open in Command prompt
  3. Follow the commmand prompt installation instructions here: https://git-lfs.github.com/

Having trouble remembering all the git commands and workflow? Try these tips/resources

Oh shit, git!

Great Youtube Tutorial

Quick cheat sheet (more advanced) The #1 most important command to know when using the git workflow is: git checkout -b new-branch-name old-branch-name #switch to new branch from old branch

and to visualize your branches: git branch -a #see all local and remote branches, as well as where is the head pointing to

Sometimes your branches don’t track from their upstream masters. Here’s a way to combat that Reasoning: If you ever change your remote branch, you’ll probably break the remote tracking as well. git branch --set-upstream-to origin/[branch name]

#To merge branches with no fast forward the HEAD must be on the destination branch git merge --no-ff source-branch

#to delete a branch, git branch -d branch-to-be-deleted

#When using multiple subtrees on Github.com or another remote branch use, git subtree push --prefix [directory-to-push] origin [subtree destination]

#If you’re working on a branch and want to stash those changes on another branch (like a dev)

git stash
git stash branch <branch name>

Helpful for maintaining forks of larger projects for upstream tracking: Keeping the forked repo synced with the main repo most important info is:

git fetch upstream
git rebase upstream/{branchName}

#in case you need to force push to a subtree: http://stackoverflow.com/questions/12644855/how-do-i-reset-a-heroku-git-repository-to-its-initial-state/13403588#13403588

git remote rm public

rm Remove the remote named . All remote tracking branches and configuration settings for the remote are removed.