Git commands

Initialization

 git config --global user.name "John Smith"
 git config --global user.email "john.smith@gmail.com"

Creating/cloning repository

 # start a new project
 git init new-project

 # clone project from github
 git clone https://github.com/kungfusheep/empty-project-typescript.git

 # clone project from local machine
 git clone git@4.4.4.4:Dir1/Dir2/manual.git

Changing local copy

 # add file 'file.md'
 git add file.md

 # add all newly created files (except those specified in .gitignore)
 git add .

 # commit changes
 git commit -a -m "commit message"

 # check status
 git status

 # diff with repository
 git diff

Updating remote repository

 # Send local updates to remote repository
 git push

 # Incorporate changes from remote repo with same name into the current branch
 git pull
 git pull origin

 # Merge the remote branch 'coolest' into current local branch
 git pull origin coolest

Branches

 # Find the name of current branch
 git branch

 # Create new branch named 'test-branch'
 git branch test-branch

 # Make 'test-branch' the current branch
 git checkout test-branch

 # Merge 'test-branch' with master
 git merge test-branch

 # Delete branch
 git branch -d test-branch

Github operations -fork and pull

Tutorials on forking and pull request

https://help.github.com/articles/fork-a-repo/ https://gist.github.com/Chaser324/ce0505fbed06b947d962 https://yangsu.github.io/pull-request-tutorial/

Forking a repo

 # There is no fork command in git, do it online at github

http://stackoverflow.com/questions/6286571/are-git-forks-actually-git-clones

 # Then -
 git clone https://github.com/YOUR-USERNAME/empty-project-typescript.git
 git remote add upstream https://github.com/kungfusheep/empty-project-typescript.git
 git remote -v

Sending pull request

# You can either submit pull request online at github 
#
# or use pull as git feature 
git request-pull

# tutorial

https://git-scm.com/docs/git-request-pull

Books and References

 # Git tower cheat sheet

https://www.git-tower.com/blog/git-cheat-sheet/

 # Github cheat sheet

https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf

http://ricostacruz.com/cheatsheets/

 # Book1 - Pro Git (git-scm)

https://git-scm.com/book/en/v2

 # Book2 - Pragmatic Guide to Git

https://github.com/saladinreborn/latihangit/blob/master/Buku%20GIT/Pragmatic%20Guide%20to%20Git.pdf