Git
新建一个本地分支,将一个远程分支 checkout 到新建的那个本地分支。
$ git chekcout -b <local-branch-name> <remote-name>/<remote-branch-name>
Branch '<local-branch-name>' set up to track remote branch '<remote-name>' from '<remote-branch-name>'.
Switched to a new branch '<local-branch-name>'
注意:<local-branch-name>
必须是新的本地分支,不能和已有的本地分支同名。
如果你指定的 <local-branch-name>
和 <remote-branch-name>
相同,则可简写为
git checkout --track <remote-name>/<remote-branch-name>
其中 --track
可简写为 -t
。
git push
$ git push
fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use
git push <remote-name> HEAD:master
To push to the branch of the same name on the remote, use
git push <remote-name> HEAD
To choose either option permanently, see push.default in 'git help config'.
$ git push -u origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 231 bytes | 231.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com/uname/reponame.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Local branch 'master' set up to track remote branch 'master' from 'origin'.
$ git merge --allow-unrelated-histories master
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
References
Squash several Git commits into a single commit