我做了一个提交并推动回购.后来我通过使用修改了提交消息git commit --amend,在弹出窗口中我输入了新消息.我可以通过看到新消息git log.经过这一切,我的git status节目就像这样.我不知道如何将这个变化推向回购.
On branch master
Your branch and `origin/master` have diverged,
and have 1 and 1 different commit(s) each, respectively.
Run Code Online (Sandbox Code Playgroud)
期待一个可行的解决方案.
它说,在git-book中
"起源"并不特别
就像分支名称"master"在Git中没有任何特殊含义一样,"origin"也没有.虽然"master"是运行git init时启动分支的默认名称,这是它被广泛使用的唯一原因,但 "origin"是运行git clone时远程的默认名称.如果你改为运行git clone -o booyah,那么你将拥有booyah/master作为你的默认远程分支.
也就是说,我们可以用默认的分支名称作为主或主要分支或类似的东西.我没有看到任何选项man git-init会repo使用不同的默认分支名称初始化我.
Github显示了如何在她的设置页面中设置默认分支名称.但我不是在谈论如何在任何特定的git托管网站中设置它.我只是严格询问git,而不是任何特定的git托管网站.
有没有办法做到这一点 ?
我从github.com分叉了一个回购,并设置了上游远程.以下是我的回购
[ Leezhm LIZHM ~/Developments/OF_GIT ] git remote -v
origin git@github.com:leezhm/openFrameworks.git (fetch)
origin git@github.com:leezhm/openFrameworks.git (push)
upstream https://github.com/openframeworks/openFrameworks.git (fetch)
upstream https://github.com/openframeworks/openFrameworks.git (push)
Run Code Online (Sandbox Code Playgroud)
当我使用这个命令
git fetch upstream develop
git merge upstream/mac8
Run Code Online (Sandbox Code Playgroud)
它总是出现以下错误
fatal: 'upstream/mac8' does not point to a commit
Run Code Online (Sandbox Code Playgroud) 当我克隆一个远程存储库时
git clone 'repo_url'git pullgit status我收到这条消息 -
On branch master
Your branch and 'origin/master' have diverged,
and have 41 and 20 different commits each, respectively
Run Code Online (Sandbox Code Playgroud)
当我使用时,git pull -a我没有这个问题.
远程仓库上的东西是不同步的吗?与HEAD和主人?我如何解决它?
编辑1:
当我运行git branch -a:这就是它的样子......
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/clothes
remotes/origin/dunnesBranch
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
编辑2:
在我看来,origin/master并没有指向最新的代码......然后我运行'git clone'然后运行
git reset --hard origin/master
'git pull'并尝试合并因冲突而失败...
我想......远程仓库的HEAD指向最新的提交,origin/master指向另一个不同的旧提交...我可以在运行git show时验证这一点...
我是git的新手,并试图围绕分支的工作方式.根据文档git checkout
更新工作树中的文件以匹配索引或指定树中的版本.如果>没有给出路径,git checkout也会更新HEAD以将指定的分支设置为>当前分支.
所以据我所知,我工作的目录中的文件(我执行git init的文件)应该根据我所在的分支进行更改.我很困惑,因为当我在分支之间切换时不会发生这种情况.在切换分支之前我正在编辑的编辑存在于我切换到的分支中.我做错了什么或git checkout不能这样工作,我只是误解了文档?
我曾使用 Mercurial,但现在使用 Git。我对 Git 的理解有些困难,你能帮我吗,Git 命令(如 Mercurial)的替代品有哪些:
hg up -C
hg revert --all
hg purge
Run Code Online (Sandbox Code Playgroud)
如果我与 Mercurial 命令“ hg up”发生一些冲突,我可以运行hg revert --all & hg purge或之类的命令hg up -C。
git pull如果我不想继续,而只是恢复到原始状态,或者更新没有冲突的文件(例如),那么在文件发生冲突后我该怎么办hg up -C?