-u
選項設置您的存儲庫中的默認值,以跟蹤的origin
。因此,默認情況下,push
和pull
將使用origin
和my_new_branch
。此後,您將不需要提供這些參數。這裏是一個例子:
$ mkdir foo; cd foo; git init; touch README; git add README; git commit -m 'README'
Initialized empty Git repository in /private/tmp/foo/.git/
[master (root-commit) 03f3d46] README
0 files changed
create mode 100644 README
$ cd ..; git clone foo bar; cd bar
Cloning into 'bar'...
done.
$ git checkout -b my-br
Switched to a new branch 'my-br'
$ touch INSTALL; git add INSTALL; git commit -m 'INSTALL'
[my-br 627d6db] INSTALL
0 files changed
create mode 100644 INSTALL
$ git push -u origin my-br
Counting objects: 3, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 245 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /tmp/foo
* [new branch] my-br -> my-br
Branch my-br set up to track remote branch my-br from origin.
$ touch Makefile; git add Makefile; git commit -m 'Makefile'
[my-br f2390c1] Makefile
0 files changed
create mode 100644 Makefile
$ git push
Counting objects: 3, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 255 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /tmp/foo
627d6db..f2390c1 my-br -> my-br
請注意,最後git push
使用正確的默認值。 主要的遠程存儲庫可以從您的存儲庫中粉碎它。
那麼,製作本地遙控器並按照我所說的方式推動它並不會給其他人帶來問題? btw:當我們在遠程源列表中執行'git remote show origin'時,我們能看到本地分支嗎?因爲我看不到我的。 – ANW