几天前我从GitHub上撤了一个项目.我已经发现GitHub上有几个叉子,我忽略了我最初采用的那个.如何确定我拉出的哪个叉子?
我知道我可以这样做git branch --all,这向我展示了本地和远程分支,但是向我展示它们之间的关系并没有那么有用.
如何以显示哪个本地分支正在跟踪哪个远程的方式列出分支?
如何检查远程存储库是否已更改,我需要拉?
现在我使用这个简单的脚本:
git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1
Run Code Online (Sandbox Code Playgroud)
但它相当沉重.
有没有更好的办法?理想的解决方案是检查所有远程分支,并返回已更改分支的名称和每个分支的新提交数.
一个项目可以在Git中有两个(或更多)"起源"吗?
具体来说,添加github存储库时会出现此错误:
$ git remote add origin https://github.com/Company_Name/repository_name.git
fatal: remote origin already exists.
Run Code Online (Sandbox Code Playgroud) 我不确定为什么这不起作用.当我这样做时git branch -a,这就是我所看到的:

我正试图从在线GitHub存储库上的DownloadManager中取出.我试过了
fatal: Couldn't find remote ref downloadmanager. Unexpected end of commands stream'fatal couldn't find remote ref remotes/origin/DownloadManager. Unexpected end of commands stream有什么我想念的吗?在Xcode中,当我尝试连接到存储库时,没有任何东西出现.我过去曾能够推动它.但是在我拉最近的变化之前,我无法再次推动.
我经常修改功能分支,然后强制将它们推送到服务器.
git push --force origin feature-mongodb-support
Run Code Online (Sandbox Code Playgroud)
有没有捷径git push --force origin <current branch>?
我见过有人在做
git merge
Run Code Online (Sandbox Code Playgroud)
即使用没有参数的"git merge".看起来它可能会做一些有用的事情.但是我在git-scm.com上找不到这个场景的文档.
在这种情况下,"git merge"做了什么?
如何从命令行/终端获取主分支名称?
\n\n我知道默认情况下会调用主分支master,但是可以将其重命名为他们想要的任何名称。
PS\xe2\x80\x94如果能得到本地和远程主分支的名称就好了。
\n\n编辑:我所说的main branch其他人可能会称之为default branch或stable branch。它\xe2\x80\x99是你(应该)将所有内容(稳定/工作)合并到其中的一个。
我有一个my-feature分支,被推到原点进行代码审查.它不是共享的.最终它将合并到我的团队中共享的develop分支中.我想将我的分支重新设置为保持历史清洁,然后将我的功能分支合并到develop中.这就是我一直在做的事情:developmy-feature
$ git checkout my-feature
// do some work. make commits.
$ git rebase develop
// fix some conflicts
$ git add .
$ git rebase --continue
Run Code Online (Sandbox Code Playgroud)
成功重新定位后,我检查状态:
$ git status
On branch my-feature
Your branch and 'origin/my-feature' have diverged,
and have 155 and 1 different commit each, respectively.
(use "git pull" to merge the remote branch into yours)
$ git what do I do here?
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做.如果我git pull,那么我注意到我会得到一些没有意义的冲突.有人说强行推,但我很担心.强制将我的主题分支推送到原点是否正常? …
我正在学习GIT(使用Git Flow),我知道使用StackOverflow代替书本不好.
我参与了一个项目.由G1和G2组维护的有两个名为F1和F2的特征分支.假设F1依赖于F2并且G1 published使用其分支git flow feature publish F1.
现在G2需要跟踪F1,并且可能会不时在F1之上重新进行基础测试.为此,我需要使用红色git flow track
所以我(G2)使用了这样的东西
git flow feature checkout F2
git flow feature track F1
Run Code Online (Sandbox Code Playgroud)
但是Git说的如下:
Branch 'feature/F1' already exists. Pick another name.
Run Code Online (Sandbox Code Playgroud)
然后我尝试了一个没有的名字,希望它会在某个时候问我需要跟踪的分支.但后来我收到了这条消息.
git flow feature track F1_track
Branch 'origin/feature/F1_track' does not exist and is required.
Run Code Online (Sandbox Code Playgroud)
我做些傻事吗?这可能是我安装的问题吗?
我相信你明白我想做什么,请你在这个问题上帮助我.
例如,通过给定一个 Git 远程跟踪分支的名称,upstream/develop如果有的话,如何找到哪个本地分支跟踪它?
如果可能,我正在寻找一种不依赖于 shell 脚本并且也适用于 Windows 的解决方案。
这不是 找出本地分支正在跟踪哪个远程分支,如果我有多个远程分支,我可能在所有远程分支中都有"主". git branch返回master但我不知道我所在的主分支是在remoteFoo还是remoteBar中.例如,我可能会这样做:
git clone someRepo.git
cd someRepo
git remote add anotherRemote otherremoteURL
Run Code Online (Sandbox Code Playgroud)
然后git remote显示
someRepo
anotherRemote
Run Code Online (Sandbox Code Playgroud)
我能做的git checkout -b master someRepo/master还是git checkout -b master anotherRemote/master和git branch会说"主人",在这两种情况下.我如何取回第一部分"someRepo"或"anotherRemote"?
你认为我可以使用,git remote show但它需要一个参数,你想要信息的遥控器的名称.
$ git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git remote show
someRepo
anotherRemote
Run Code Online (Sandbox Code Playgroud)
随着git branch我得到的是什么电流指示: …
git ×12
github ×2
bash ×1
command ×1
git-alias ×1
git-flow ×1
git-pull ×1
git-push ×1
git-rebase ×1
git-remote ×1
repository ×1
shell ×1
terminal ×1