Here actually first post for memory and besides of that fact that there're dozens resources about GIT commands in Internet I'd like to have my own place for them.
1. GIT
installation for Windows:
2. GIT
installation for Linux:
apt-get install git-core
3. GIT
installation for OSX:
4. Setting
up user preferences (name, email)
git config --global user.name "Your
Name"
git config --global user.email
"Your Email"
5. Init
repository
git init
git clone “url” (this will clone
repo from remote)
6. Add remote
repo
git remote add “url”
6.1 View remote repo
git remote -v
6.2 Remove remote repo
git remote rm origin
7. Check
status
git status
git remote show origin (shows
remote repo)
8. Get
changes from remote
git fetch (obtains changes but
doesn’t merge them automatically)
git pull (obtains and merges
changes)
git merge origin/master (only
merges previously fetched changes)
9. Add
files to commit
git add “filename”
git add –all
git add .
10. Commit
changes
git commit –m “Commit message”
git commit --amend -m "Commit message/additional
text"
11. Submit
changes to the remote
git push origin master
git push origin “Branch name”
--force
12. Create and
switch on new branch
git checkout –b “Branch name”
13. Merging
branches
git merge “Branch name” (merges
current branch with desired one)
14.
Rebasing
git rebase “Branch name” (rebasing
changes from desired branch with current one)
15.
Reverting changes
git revert HEAD
git revert HEAD --hard
16.
Removing files from repo
git rm “File name”
17. Check
logs
git log --pretty=oneline
git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes
ago'
git log --pretty=oneline --until='5 minutes
ago'
git log --pretty=oneline --author=<your
name>
git log --pretty=oneline --all
git log --pretty=format:"%h %ad | %s%d
[%an]" --graph --date=short
git log --author="Author name"
git log --author="Author name"
18.
Creating aliases (You can just put those changes into .gitconfig file)
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.hist 'log
--pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
git config --global alias.type 'cat-file -t'
git config --global alias.dump 'cat-file -p'
19. See complete list of files in repo
git ls-tree -r "Branch name" --name-only
20. See complete list of changes for file in repo
git annotate -- "whole path to file including file name"
21. Deleting branch
git branch -D "Branch name"
git push origin --delete "Branch name"
git push origin --delete "Branch name"
This pretty much it for most interesting and important GIT commands as for me.
P.S. I'll add commands for "cherry picking" and some other later.