Lubos Rendek

The only solution is determination.

Basic Git Survival Commands

| Comments

Here is a list of basic git commands. For all git beginners the list should suffice in order to get started wit GIT repositories. Initial Setup

1
2
3
4
git config --global alias.co checkout - use alias for checkout
git config --global core.editor "vim -f" - set default editor to use with vim
git init - initialize new repository
.gitignore - edit this file to instruct git to ignore files and directories

Adding and Committing

1
2
3
4
5
6
7
8
9
git add main.cpp - add file/s to stage
git add . - add all files and directories
git rm main.php - remove file
git commit -m "message text" - commit changes
git commit -a -m "message text" - commit changes without prior git add . command
git status - show status of files on your local git
git log - list all commits
git checkout -f - revert all changes to the previous commit
git stash - throw away all changes and go back to last version

Branch, Edit and Merge

1
2
3
4
5
6
7
git checkout -b XYbranch - create and switch to new branch called 
git branch - view which branch is selected ( * )
git checkout YZ - change branch
git checkout master - change to master branch
git merge YZ - merge branch YZ with a currently selected branch
git branch -d YZ - delete branch after merge 
git branch -D YZ - delete branch without previous merge with master branche

Remote upload and download

1
2
git push -u origin master - upload to git server or sometimes simply git push
git pull - download and merge data from git server

Comments