git
Git is a distributed version control and source code management (SCM) system.
SSH public key generation
- ls ~/.ssh
 - ssh-keygen # create ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub keys
 - cat ~/.ssh/id_rsa.pub # shows key to be sent to the git server admin
 
Config
- git config --global user.name "John Doe"
 git config --global user.email johndoe@example.com
- git config --list
 
Create repository
cd <project>
- git init #create folder .git
 - touch README.md
 - touch ,gitignore
 - git add .
 - git commit -m 'Initial commit'
 
Clone repository
git clone git@git.server.net:repository.git # by ssh
git clone https://git.server.net/repository.git #by https
- cd repository
 
Branch creation based on current branch
- git branch #show current branch
 - git checkout -b B/20130801/BRANCH-XYZ master # create new branch based on branch master
 - git branch -m B/20130801/BRANCH-XYZ B/20130801/BRANCH-ZZZ # rename local branch
 - git push origin B/20130801/BRANCH-ZZZ # push branch B/20130801/BRANCH-ZZZ to remote
 
Commit to remote branch
- git commit -am 'Message commit xyz ' --all #commit locally
 - git pull origin B/20130801/BRANCH-ZZZ # sync with remote branch # fix conflicts and commit conflict resolution
 - git push origin B/20130801/BRANCH-ZZZ # send changes to remote branch
 
Merge to other branch
- git checkout master # merge destination branch
 - git pull origin master # sync dest branch
 - git merge --no-ff B/20130801/BRANCH-ZZZ # merge branch B/20130801/BRANCH-ZZZ to branch master
 - git pull origin master
 - git push origin master
 
Reapply .gitignore
cd <projectFolder>
- git rm -r -f --cached .
 - git add .
 - git status #check files to be commited
 
