Initialize local git repository
git init
Add a particular file to a repository
git add README.md // Example: README.md file
Add all uncommitted files to the repository
git add .
Add configure name and email for each commit
git config --global user.name lorence // lorence
git config --global user.email [email protected] // [email protected]
Add message to your commit
git commit -m "Your first commit here"
Observe all history
git log
Add remote NAME/URL to local source
git remote add origin <URL>
Push your changes to remote repository
git push origin master // branch name: master
Clone any repository
git clone <URL>
Update the current working directory
git pull origin master // branch name: master
Check different in between commits
git diff HEAD~1 HEAD
Download files from any repository
git fetch origin master // branch name: master
Download files from all repositories
git fetch origin // control name: origin
Create new branch
git branch -a <branch name>
Switch branch to another branch
git checkout <branch name>
Delete local branch
git branch -D <branch name>
Delete remote branch
git push origin --delete <branch name>
Merge branch A to branch B
git checkout B
git merge A
Push a branch locally to remote branch base specific branch name
git push -u <Remote URL> <branch-name>
Observe all branches
git branch -a
or
git branch --list
Observe uncommitted or committed file
git status
Revert your changes
git revert
Revert based on hash code
gitk
git revert <hash code>
Help
git command -help