Git is a version control system. This is my first journey to GitHub.
Here are some commands in Git(learn from Liao's wonderful blog):
$ echo "# <repo>" >> README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin git@github.com:<user>/<repo>.git
$ git push -u origin master
$ git remote add origin git@github.com:<user>/<repo>.git
$ git push -u origin master
$ git clone git@github.com:username/reponame.git
$ git pull [remote] [local]
$ git push [remote] [local]
$ git init
$ git add file
$ git commit -m statement
$ git log
$ git log --pretty=oneline
$ git reflog
$ git reset --hard commit_id
$ git diff HEAD -- file
$ git checkout -- file
$ git reset HEAD file
$ git checkout -- file # and then undo the edit in WD
$ there is nothing you can do
$ rm file
$ git rm/add file
3.1 All work should be done in dev branch, leaving master branch stable. Teammates merge their own changes to dev branch, and merge dev branch to master branch when necessary.
$ git branch
$ git branch <name>
$ git checkout <name>
or
$ git checkout -b <name>
$ git merge <name> # using mode of "Fast forward", don't save info of branch
$ git merge --no-ff -m [statement] <name> # abandon "Fast forward", create a new commit in merge process and keep the info of branch
$ git log --graph --pretty=oneline --abbrev-commit
$ git branch -d <name>
$ leave to be done
$ leave to be done
$ git checkout -b <name> origin/<name> # create corresponding branch in local repo
$ git branch --set-upstream <name> origin/<name> # build connection between local branch and remote branch
$ git add file
$ git commit -m statement
$ git push origin <name>
$ leave to be done
Tag is a snapshoot of repository and immovable pointer to some commit with simpler id, always used for version release
$ git tag <tagname,say"v1.0"> # on the newest commit
$ git tag <tagname> <commit_id> # on specified commit
$ git tag -a <tagname> -m <statement> <commit_id> # create
$ git tag -d <tagname> # delete tag in local repo
$ git push origin <tagname> # push some tag to remote repo
$ git push origin --tags # push all tags to remote
$ git tag -d <tagname> + git push origin :refs/tags/<tagname> # delete tag in remote repo
Please refer to gitignore for various configuration files
# Python
__pycache__/
*.py[cod]
# File
*.jpg
*.mp4
*.h5
*.ckpt
1) ignore system automatically generated files
2) ignore intermediate and executable files generated during compiling
3) ignore configuration files with sensitive information
$ git add -f <file>
$ git check-ignore -v <file>
with '--global' the configuration will work for the current user, otherwise it will only work for the current repository.
The configuration file for each repository is its .git/config, and that for current user is .gitconfig in the user home directory.
$ git config --global alias.st status
$ git config --global alias.co checkout
$ git config --global alias.ci commit
$ git config --global alias.br branch
$ git config --global alias.unstage 'reset HEAD'
$ git config --global alias.last 'log -1'
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"