Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git 技巧之 --set-upstream #5

Open
youngwind opened this issue Dec 13, 2015 · 3 comments
Open

git 技巧之 --set-upstream #5

youngwind opened this issue Dec 13, 2015 · 3 comments
Labels

Comments

@youngwind
Copy link
Owner

下面的情况我们经常遇到:

从develop分支checkout出feature-a分支,干完活之后git push origin feature.假如再次修改的话,还得再次git push origin feature.每次都要打全才能push成功。

但是,其实可以通过 --set-upstream 让remote的某个分支和本地的某个分支关联起来,这样只要git push一下,就会push到对应的远程分支了。

git branch --set-upstream my_branch origin/my_branch

更简单地方法

上面那个命令太长了,老记不住,后来找到一个更简单了。
第一次push的时候:

git push -u origin my_branch

之后就可以直接push和pull了。

@tonicmuroq
Copy link

也可以设置好 .gitconfig 里的

[push]
    default = current

在当前分支下直接 git push 就可以了

@Rhan2020
Copy link

可以直接 git push
然后 git 会提示 :
git branch --set-upstream my_branch origin/my_branch
复制、黏贴、回车。。。

@imfht
Copy link

imfht commented Aug 28, 2018

新版的git 移除了--set-upstream命令

fatal: the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead.

git version: 2.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants