Keywords: git, pull, branch

Common Commands

1, abort merge

git merge --abort

2, switch branch

git checkout master

or create local branch and switch to it if HEAD detached:

git checkout -b master remotes/origin/master --

3, clone only a single branch

git clone [url] -b [branch-name] --single-branch

4, Get the current branch name in Git?

git branch | grep \* | cut -d ' ' -f2

5, Revert file

git reset HEAD <file>

6, Change connection from SSH to HTTPS

git remote set-url origin https://...
git remote set-url --push origin https://...

You can view the configured remotes with git remote -v, which should now show your updated URLs.

Reference:
https://stackoverflow.com/questions/30683399/how-to-change-a-connection-to-github-from-ssh-to-https

Sync Fork

Steps:

1, add remote forwarded to upstream(father repository)

git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

2, fetch from upstream

git fetch upstream

3, switch to branch you want to merge, e.g. master:

git checkout master

If upstream has a branch which has the same as origin, you must designate the full name of your origin branch, e.g.:

git checkout remotes/origin/master

4, merge upstream/master to your local master branch.

git merge upstream/master

5, push to your remote fork

git push

Reference:
How to sync branch forked on git
https://jinlong.github.io/2015/10/12/syncing-a-fork/


上帝等待着人类在智慧中获得新的童年。──泰戈尔(Rabindranath Tagore)