我一直在使用Git一段时间,并且最近只下载了一个更新,以便在我尝试时发现此警告消息push.
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
Run Code Online (Sandbox Code Playgroud)
我显然可以将它设置为所提到的值之一,但它们是什么意思?simple和之间有什么区别matching?
如果我在一个客户端上更改它,我是否需要在我共享回购的其他客户端上做任何事情?
我在Git中创建了一个新分支:
git branch my_branch
Run Code Online (Sandbox Code Playgroud)
推它:
git push origin my_branch
Run Code Online (Sandbox Code Playgroud)
现在说有人在服务器上做了一些更改,我想从中拉出来origin/my_branch.我做:
git pull
Run Code Online (Sandbox Code Playgroud)
但我得到:
You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use something like …Run Code Online (Sandbox Code Playgroud) 当我输入时git diff,我想用我选择的视觉差异工具(Windows上的SourceGear"diffmerge")查看输出.如何配置git来执行此操作?
是否有快捷方式告诉Git将当前跟踪分支推送到原点?
注意:我知道我可以更改默认的推送行为,但我正在寻找一种不会改变默认行为的临时解决方案.
例如,假设我在feature/123-sandbox-tests我将使用的分支上
git push origin feature/123-sandbox-tests
Run Code Online (Sandbox Code Playgroud)
这很乏味.我正在寻找一条捷径,比如说
git push origin current
Run Code Online (Sandbox Code Playgroud)
git知道当前是什么feature/123-sandbox-tests.
编辑:从版本2.0开始,git的默认行为已更改为更直观的行为,这是我想要实现的.有关详细信息, 请参阅此SO问题
编辑2:ceztko的答案是最佳答案,因为它允许推送当前分支,无论设置如何.
如果有人删除了一个远程分支,因为工作结束了,我不知道,我不会做git fetch --prune,最终我会推回已删除的分支.
是否有可行的解决方案强制git在获取/拉取时使用剪枝模式而不必每次都指定它?
HEAD和masterGit有什么区别?
我在GitHub上做了一个项目的克隆,并希望将我的更改推送到远程.但是我应该推动哪一个?

即使在阅读了这个问题之后:git-push-current-branch,我仍然很难弄清楚我应该如何编写我的git push命令.正如问题链接中所提到的,文档中并不清楚.
我想用我的'真实世界'的例子.以下是我在git status分支顶层执行命令时看到的内容:
在分支amd_qlp_tester上
您的分支在5次提交之前超过'origin/amd_qlp_tester'.
等等...
所以我的分支名称是,amd_qlp_tester但它从主分支"分支"(如果由于我的SVN背景我的条款错误).但是还有名字`origin/amd_qlp_testser'
那我怎么说出我的推送命令呢?
是这些中的任何一个:
git push origin/amd_qlp_tester?
git push origin amd_qlp_tester?
git push amd_qlp_tester?
git push origin?
git push?
Run Code Online (Sandbox Code Playgroud) 在releases/rel_5.4.1使用Git GUI 检查远程分支后,当我尝试执行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 origin HEAD:releases/rel_5.4.1
To push to the branch of the same name on the remote, use
git push origin rel_5.4.1
Run Code Online (Sandbox Code Playgroud)
我不知道Git在说什么.我可能想要推进,origin releases/rel_5.4.1因为那是我检查过的分支.所以这两种选择对我来说都不正确.
git status说我在分店rel_5.4.1.
这是我出现的分支.git/config:
[branch "rel_5.4.1"]
remote = origin
merge = refs/heads/releases/rel_5.4.1
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?
我有一个跟踪几个远程分支的git存储库:
$ git branch -a
* master
remotes/git-svn
remotes/origin/master
remotes/trunk
Run Code Online (Sandbox Code Playgroud)
当我尝试设置默认值时,我收到以下错误:
$ git branch --set-upstream-to=origin/master master
warning: refname 'origin/master' is ambiguous.
fatal: Ambiguous object name: 'origin/master'.
Run Code Online (Sandbox Code Playgroud)
我想删除一些远程主分支,但主引用仍然存在.如何删除它们才能将默认上游分支设置为origin/master?
$ git show-ref master
cba97a58c99743c355b569bbf35636c8823c2d96 refs/heads/master
6726b4985107e2ddc7539f95e1a6aba536d35bc6 refs/origin/master
d83f025cd3800ed7acd76b2e52ae296e33f1cd07 refs/original/refs/heads/master
cba97a58c99743c355b569bbf35636c8823c2d96 refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud) 我经常修改功能分支,然后强制将它们推送到服务器.
git push --force origin feature-mongodb-support
Run Code Online (Sandbox Code Playgroud)
有没有捷径git push --force origin <current branch>?