I’ve a lot of experience as a software developer using centralized version control systems like Subversion, Team Foundation, and SourceSafe. For the past month and a half I’ve been using Git, a distributed version control system for my side projects (in conjunction with BitBucket and possible GitHub as remote repositories).
I’ve been using the excellent Getting Git Right tutorial by Atlasssian to get started. This post is a record of the Git commands I’ve been using at the command line on a regular basis, which I’ll update at regular intervals (I want to learn at the command line first before using a GUI to hide the complexity).
git init git clone git status git log git add git commit git commit --amend // Brings up editor to amend last commit message git commit -m <message // Wipe out last commit message; replace with new git branch // lists all branches in repo git branch <branch> // creates new branch git branch -d <branch> // deletes branch git checkout <branch> // switches to new branch git checkout <hash> // checkout a previous commit, preserves subsequent commits though (bit.ly/1J8RaqV) git push git push <remote> <branch> // pushes local branch to remote repo git remote git push --force <remote> <branch> // forces push of remote branch git stash git stash list git stash apply
I also figured out how to push a local git repository to Bitbucket at the command line (prior to this I created repos in Bitbucket and pulled them down to my local machine).
Again the Atlasssian web site was extremely helpful, I found several good pages on how to import code from an existing project, using the SSH protocol with Bitbucket, setting up SSH for Git and Mercurial, and rectifying SSH Authenticity errors.