Some basics git commands

git cheatsheet

Basic workflow

# setup the project  
git clone github/project.git  
git branch FeatureX  
git co FeatureX

# make some changes  
git status  
git add .

# commit changes  
git commit -m 'commit message'

# push changes to branch  
git push origin branch-name

# next pull request/merge with master on github or command line  

Sometimes you don’t want to track some files(like local env configuration settings)

# no track file  
git update-index --assume-unchanged Gemfile .ruby-version

# track file again  
git update-index --no-assume-unchanged path/to/file.txt  

About branch

# view hidden branch or detached  
git branch -a

# track branch  
git branch branch_name origin/branch_name

# sync a branch with master

# update master  
git checkout master  
git pull

# change to the branch  
git checkout branch  
git merge origin/master

# fix conflicts  
# commit changes  
# branch is updated

Steps to merge pull request from branch, take it from Github

# Step 1: From your project repository, bring in the changes and test.

git fetch origin  
git checkout -b branch-name origin/branch-name  
git merge master

# Step 2: Merge the changes and update on GitHub.

git checkout master  
git merge --no-ff branch  
git push origin master  

Alias for .gitconfig

co = checkout  
ci = commit  
st = status  
br = branch  
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short  
type = cat-file -t  
dump = cat-file -p  
tree = log --oneline --graph --decorate --all  
bra = branch -a  
cbr = branch -l  

Some reference

linux  git  shell