我使用以下命令推送到我的远程分支:
git push origin sandbox
Run Code Online (Sandbox Code Playgroud)
如果我说
git push origin
Run Code Online (Sandbox Code Playgroud)
这会推动我的其他分支的变化,还是只更新我当前的分支?我有三个分支:master,production和sandbox.
该git push文件是不是这个很清楚,所以我想澄清这一点为好.
哪些分支和遥控器可以git push完全更新以下命令?
git push
git push origin
Run Code Online (Sandbox Code Playgroud)
origin 上面是一个遥控器.
据我所知,git push [remote] [branch]只会将该分支推送到远程.
是否有快捷方式告诉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一段时间,但我自己从来没有设置过新的远程仓库,我一直很好奇这样做.我一直在阅读教程,我对如何让"git push"工作感到困惑.
如果我只是用git push它要求我查看默认分支(?)指向?它为我提供的这两个选项有什么区别?
git config --global push.default matching
git config --global push.default simple
Run Code Online (Sandbox Code Playgroud)
匹配只是推动我在本地仓库上的任何分支,如果它们不匹配,我必须手动告诉它推送我所拥有的任何新的本地分支,对吗?这是最好的做法还是最简单的?
从功能上讲,在分散的工作流程中,我没有看到配置设置simple和current选项之间的区别push.default.
current将当前分支推送到指定远程上的同名分支.simple对于当前分支的跟踪和任何未跟踪的遥控器,它将有效地做同样的事情(它在两种情况下都强制执行相同的分支名称).
有人可以解释我失去的分散工作流程之间的任何重要差异吗?
git-config的手册页列出了push.default的这些选项:
nothing - do not push anything.
matching - push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.
upstream - push the current branch to its upstream branch.
tracking - deprecated synonym for upstream.
current - push the current branch to a branch of the same name.
Run Code Online (Sandbox Code Playgroud)
在大多数情况下,我会假设推送到分支的上游分支与推送到同名分支相同,因为上游分支通常具有相同的名称,并且因为同名的分支("当前" )通常(或总是按定义?)是上游.那有什么区别?
UPDATE:为的git-config中的男子页面已经更新(如人们所期望的),这样的区分做出有可能是一个更加清晰了.
我有一个当地的git项目,我想添加到gitolite.显然这很难,所以我放弃了这个想法.我创建了一个新的gitolite repo,将它添加到gitolite-admin/conf/gitolite.conf并提交并推送更改.然后我git clone git-noah:project-name成功地克隆了新的回购.然后我将除.git之外的所有文件和文件夹复制到project-name文件夹.我做到了,
git add -A
git commit -a -m "Moved to new repo."
git push
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
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
See 'git help config' and search for 'push.default' for …Run Code Online (Sandbox Code Playgroud) 当我在Git中推送到远程时,我收到此警告:
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
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if …Run Code Online (Sandbox Code Playgroud) 我从git克隆了存储库A的主分支,并创建了自己的分支Li.我前段时间做了一些改动,把当地李的内容推到了偏远的李.
现在我已经从远程主机到本地主分支以及从本地主分支到本地Li的一些更新,我正在尝试将更新从本地Li推送到远程Li.但是,当我尝试运行时:
git checkout Li
git push origin Li
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
error: failed to push some refs to 'git@github.com:anodejs/system.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
请注意,我的本地主分支已更新(我调用了git pull origin master)并合并到本地Li分支.但是,我确实在本地Li添加了一个新文件,因此本地Li与本地主人不同(但这不应该,对吧?)
谢谢,李
我git在GitHub发布Windows应用程序之前从未使用过,所以我从未在命令行中使用它.
所以这是我的情况:
我做了一些提交master,然后切换分支并在那里做了一些提交.所有这一切都没有推向GitHub.当我点击syncwindows应用程序(我假设它git push)时,令我惊讶的是,我的所有提交都被推送到我的新分支 - 甚至是我在进行时所做的提交master.
由于这是Windows应用程序的行为,我想我必须使用命令行.将提交推送到远程控制器上的正确分支
的正确git push命令是什么?
我经常跑:
git push
git tag v4.7
git push --tags
Run Code Online (Sandbox Code Playgroud)
第一个和第三个操作都连接到服务器,这浪费了时间.
我想通过只推一次来加快速度.什么命令会实现这个目标?
它是一个bash 脚本,需要在任何分支中运行良好,而不仅仅是master.
阅读手册,我认为不是git push all解决方案:
--all:不是命名每个引用推送,而是指定refs/heads /下的所有引用都被推送.
--tags:除了在命令行中明确列出的refspec之外,还会推送refs/tags下的所有引用.
git ×10
git-push ×5
git-branch ×2
push ×2
branch ×1
git-config ×1
git-pull ×1
git-remote ×1
git-tag ×1
github ×1
gitolite ×1