Created
January 9, 2018 12:56
-
-
Save yanxun827/f7a20ec5314da6b963e5d7c54620f66b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config —-global | |
git config —-list | |
git init [repository name] (create a local repo) | |
git clone [repository name] copies a remote repo to store it locally | |
git remote add origin [remote repo link] (links up the local and remote repos) | |
git push -u origin master | |
git add [filename] | |
git add *.html adds all untracked html files | |
git add . adds every untracked files(including files in subdirectories) | |
git diff (works for file that has been modified when not staged(added)) | |
git diff —-staged (works for file that has been staged) | |
git branch [branch name] (create new branch from current branch) | |
git checkout [branch name] (go to branch) | |
git checkout -b [branch name] (create new branch and go to branch) | |
git branch (lists all the branches and which branch currently in) | |
git branch -d [branch name] | |
git merge (has to be done on the receiving branch, and if no commits on receiving branch, it will be a fast forward merge, if not, need to insert message.) | |
git commit -m "message for this whole commit (including all files)" | |
If commit without message, an editor (vim) would be opened to allow message to be entered. Type :wq to save the message and exit vim. | |
git push (push to remote repo) | |
git pull | |
To sync original repo fork with own fork | |
```bash | |
git fetch upstream | |
git merge upstream/master | |
``` | |
However, pull would introduce merge commits. To avoid that to have a linear history, [use these commands](https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/): | |
```bash | |
git fetch origin | |
git rebase −p origin/develop | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment