Git Use

Quick guide book:

Clone repo

1
$ git clone

Initialize new repo

Initialize and push it to a new repo in Github

1
2
3
4
5
6
$ git init
$ git remote add origin https://github.com/ShuoGH/REPONAME.git

# add the repo in the github website in advance
$ git push -u origin master # first to push
$ git push origin master #after the first time

Branch

Some commend about the branches:

List branches:

1
git branch -a

Check out branch

If you want to checkout to a branch directly, just use:

1
git checkout origin/xxbranch

To create a local branch,

1
2
3
4
5
git checkout -b xx origin/xxbranch
# or use
git checkout -t origin/xxbranch` # it will create a branch with same name.
# or use `fetch`
git fetch origin xxbranch:xx # (in this way, it won't checkout to the new branch automatically)

Delete branch

To delete the remote branch:

1
git push <remote_name> --delete <branch_name>

Operation on Files

To rm the local file and make the change into git:

1
2
git rm xx 
git commit -m "xxxx"

Show the git tree

1
git log --graph --pretty=oneline --abbrev-commit