我希望能够做到以下几点:
基于其他(远程或本地)分支(通过git branch或git checkout -b)创建本地分支
将本地分支推送到远程存储库(发布),但使其可跟踪,git pull并git push立即工作.
我怎么做?
我--set-upstream在Git 1.7中知道,但这是一个创作后的动作.我想找到一种方法,在将分支推送到远程存储库时进行类似的更改.
我在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,我在练习.我创建了一个本地分支,但是当我完成时,我看到git push我的分支没有上传到存储库.我必须这样做:git push -u origin --all.
为什么是这样?不是分支是默认推送的新变化吗?为什么我需要运行第二个命令?
在git中进行高级操作时,我更像是一个新手.我使用博客框架Octopress维护我的博客.虽然Octopress自2011年以来没有任何发展,但它很好地实现了我的目的,所以到目前为止我还没想过要改变任何东西.
仅供参考,我的博客是在Github Pages上托管的.
今天,在处理新帖子时,git status显示以下消息:
On branch source
Your branch is based on 'origin/master', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
Run Code Online (Sandbox Code Playgroud)
对所有后续命令重复相同的消息,例如git add .,git commit -m 'message'和git push origin source.
如果可能的话,请指向我的pdf/web文章,在那里我可以阅读并了解它以备将来使用.
更多细节:
bash-3.2$ git branch -a
* source
remotes/octopress/2.1
remotes/octopress/HEAD -> octopress/master
remotes/octopress/gh-pages
remotes/octopress/linklog
remotes/octopress/master
remotes/octopress/refactor_with_tests
remotes/octopress/rubygemcli
remotes/octopress/site
remotes/origin/source
Run Code Online (Sandbox Code Playgroud)
如果需要更多信息,请告诉我.谢谢.
我目前已经设置了我的 git remote 来限制获取哪些分支:
git remote set-branches myOrigin myBranch
Run Code Online (Sandbox Code Playgroud)
这将适当的条目添加到.git/config:
[remote "myOrigin"]
fetch = +refs/heads/myBranch:refs/remotes/myOrigin/myBranch
Run Code Online (Sandbox Code Playgroud)
现在我想撤销这个,回到默认配置:
[remote "myOrigin"]
fetch = +refs/heads/*:refs/remotes/myOrigin/*
Run Code Online (Sandbox Code Playgroud)
如何在不手动修改我的情况下执行此操作.git/config?有git我可以运行的命令吗?
我有一个主分支,正在开发涉及相同文件的两个功能。我想要有 2 个本地分支指向同一个上游主服务器,但有不同的更改。我不想在本地提交更改,以便 IDE 保留格式,如
https://d3nmt5vlzunoa1.cloudfront.net/idea/files/2018/10/k8sCompletion.png中的边框阴影
我无法成功使用 git checkout ,因为当我在一个分支中进行更改并切换到另一个分支时,未暂存的更改也可以在其上看到。我想出的解决方案是在 2 个存储库中检查我的代码,因为 git worktree 似乎需要 2 个不同的远程分支。然而,这意味着硬盘效率低下。有办法实现我想要的吗?
我希望当我在本地分支之间切换时,即使一个分支的未暂存更改也不应该在另一个分支中可见。
在一次采访中,我被要求重构一个现有的项目。从给我的 github 存储库中,我被告知:创建一个新分支,进行更新,提交更改,推送到新分支。然后我被告知创建一个以 master 作为基础分支的 PR,并将基础分支更改为分叉的 [company] 存储库的 master 分支。
由于我以前只做过自己的项目,所以我不知道在这里做什么。我一直在谷歌搜索并试图自己弄清楚,但无法弄清楚。
git ×8
git-branch ×3
git-remote ×2
branch ×1
git-push ×1
git-worktree ×1
github ×1
github-pages ×1
repository ×1