GitHub
- Create a github account at
- Follow the https://guides.github.com/activities/hello-world/ to learn the basics about
- repository, branch, pull request, merge
- Setup working directory in your laptop
- git clone https://github.com/[account name]/[repository name].git
- Edit any file
- git add *
- git commit -m "some comments"
- git push -u origin master
- To remember to login
-
- git config credential.helper 'cache --timeout=900'
- git config --global credential.helper cache
Git
- Set default username and email
- git config --global user.name "xxx"
- git config --global user.email "xxx@yyy.xom"
- git config --global --list
- Create a new repository
- mkdir p; cd p; git init
- Clone repository
- git clone /path/to/repository
- git clone username@host:/path/to/repository
- git clone https://github.com/[account name]/[repository name].git
- show origin url
- git remote -v
- Add changes to buffer
- git add [filename]
- git add *
- Commit
- git commit -m "some comments"
- Push to master branch
- git push origin master
- Create a new branch
- git checkout -b [branch]
- show branches
- git branch
- Switch to main branch
- git checkout master
- Delete a branch
- git branch -d [branch]
- push to branch
- git push origin [branch]
- update
- git pull
- Merge
- git merge <branch>
- Tag
- git tag
- Log
- git log
- Revert back changes
- git checkout .
- git checkout [filename]
- Diff
- git diff [filename]
- Remove all unexpected files
- git clean -dfx
- add and commit at the same time
- git commit -am [messages]