We can all agree that git has become everyone’s favorite versioning system lately. Having experience with SVN and Git I can safely say that Git is not actually better but it is different. The key advantage is that it is decentralized. With Git, you can do practically anything offline, because everybody has their own repository. Making branches and merging between branches has never been easier. Git is complex, powerful and fast (since it works for Linux kernel of course). Every company and business setup has its own workflow and with SVN in my company we had a tough time adopting the version system with our business case. Git is very flexible and with its
TIMTOWTDI approach will help is meet our goals. Well, everything has its pros and cons even though the pros will obviously outrun the cons, note that Git is much harder to learn, lacks a good GUI and revisions do not have version numbers. Below I have complied a few necessary git commands in the form of a cheat sheet:
Sets the name you want to commit with.
Sets the email Address you want the author to have.
The most useful config you need to start with is
Sets to colorize the command line.
Creating a New Repository:
Initializes a new repository
Clones an existing repository.
Adding Files to be Tracked:
Adds the specified file.
Adds all files.
List all new or modified files to be committed
Shows file difference not yet staged.
Shows all commits
Show all commits summaried each in one line.
Shows changes for a specific file
Shows file differences between staging and the last file version
Tracking changes on a file about who changed what and when (annotated).
Commit changes to head
Commit any file you have added with git add or modified an added file.
If you haven’t connected your local repository to a remote server, add the server to be able to push to it
List all currently configured remote repositories:
Sends the changes to the master branch on the remote repository
Publish local changes on a remote
Branching and Related Commands:
List all existing branches
Creates a new branch based on your current head
Checkout a specified branch
Deletes a specified branch
Merge into the current head
Rebase current head onto the branch
Mark the current commit with a tag name.
Download all changes from , but don’t integrate into head
Download changes from and merge into head
Deletes the specified file form the working directory and stages the deletion.
Deletes the file from the version control system but preserves the file locally in the working directory.
List all ignored files in working project directory
Temporarily stores all modified tracked files
Restores the most recently stashed files
Lists all stashed changesets
Discards the most recently stashed changeset
Reverting and Re-doing:
Unstages the specified file, but preserve its contents
Undoes all commits after [commit] , preserving changes locally
Discards all history and changes back to the specified commit
Revert a commit by producing a new commit with contrary changes