Git notes

Typical add/commit/push workflow:

#add local change ready to commit
git add .

#git commit changes to repo
git commit -m "commit message"

#push to remote repo
git push [optional remote repo name here, eg origin, etc]

Find changes committed locally compared with remote repo, i.e. to find what you’ve committed locally but not yet pushed:

git diff --stat [remote repo name]

List associated remote repos and their locations:

git remote -v

Add a new remote repo to an existing local app/repo:

git remote add remotename remote_git_repo_url

Git in a nutshell

I’ve been using Clearcase for version control on large development projects now for several years (maybe as many as 10 years). I’d heard of the new trend in distributed version control but even outside of work, at home, I had been using cvs and then more recently, subversion.

I just started working with on some code that was using Git, and so I’m having my first taste of using a distributed vcs.

Here’s my cheatsheet for the essentials:

Add new files and/or updated files to the changeset to be included in the next commit (‘.’ is recursive, ‘*’ is wildcard for this dir only):

git add .

Take a snapshot of all changes staged (previously staged with git add)

git commit

Commit changes with a commit message:L

git commit -m "commit message"

Update text of a commit message that was incorrect:

git commit --amend -m "new message"

Push currently committed code to a remote git repo (if using one):

git push [remote name]