我一直在使用mobaXterm在Windows 10计算机(以Cygwin为基础)作为终端访问根和Python /宏。此外,我和我的同行们一直在使用Gitlab来共享这些脚本/宏。最近,我们开始使用Gitlab编写一个已经共享的LaTeX文档。我一直面临的问题是尝试使用Gitlab与我使用背页作为LaTeX编辑器进行集成。
我遵循给这里介绍如何将背页的git存储库与Github连接起来的指南,却遇到了一些烦人的问题。
首先,似乎我可以通过以下一行将背页存储库克隆到我的计算机上:git clone https://git.overleaf.com/%%%%%%%%%%%%%% note_name
其次是git remote rename origin overleaf
然后我确实通过线git pull overleaf master
所有这些似乎都没有引起任何问题。然后我通过行git remote add gitlab https://gitlab.thing.ty/folder/note_name.git添加了我的Gitlab存储库
然后,我通过git config --global push.default matching和git push gitlab对Gitlab做了初步的推动。
Username for 'https://gitlab.thing.ty':
Password for 'https://username@gitlab.thing.ty':
Counting objects: 21, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 50.81 KiB | 0 bytes/s, done.
Total 21 (delta 7), reused 0 (delta 0)
To https://gitlab.thing.ty/folder/note_name.git
ccf7614..596ba69 master -> master`然后是从背叶git pull overleaf master拉出来的
remote: Counting objects: 5, done
remote: Finding sources: 100% (3/3)
remote: Getting sizes: 100% (4/4)
remote: Compressing objects: 100% (7764/7764)
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://git.overleaf.com/%%%%%%%%%%%%
* branch master -> FETCH_HEAD
f0173f3..d3bb61b master -> overleaf/master
Merge made by the 'recursive' strategy.
Section2.tex | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)`当我需要提交更改并将更改推送到Gitlab时,我现在遇到了问题。我有这样的台词:
git commit -m "configuring git access, no major edits have been made"
On branch master
Your branch is ahead of 'overleaf/master' by 16 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean和
git push gitlab
Username for 'https://gitlab.thing.ty':
Password for 'https://username@gitlab.thing.ty':
To https://gitlab.thing.ty/folder/note_name.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to
'https://gitlab.thing.ty/folder/note_name.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.我似乎不知道如何同时管理两个不同的存储库。
发布于 2017-09-06 14:44:14
提交量最大的回购应该是在尝试任何更改之前从其中提取的。
git pull upstream master
在此之后,请确保您的gitlab回购与上游同步。
git push origin master
这样,如果您使用
git log你应该看到
commit 798a0433ad807b6127066cac3f6e33d6551ef0d4 (HEAD -> master, upstream/master, origin/master)这意味着两个repos处于相同的提交中。
在完成工作之后(最好是在一个单独的分支上完成),您需要提交这些更改。git commit --all -m "some text"
完成此操作后,您应该看到在git log中,您的新分支已经领先于upstream和origin,如果您想将这些更改集成到其中任何一个,您应该使用git rebase,这将在回购上形成一个fast-forward。我们不使用pull,因为它会在合并它们时融化所有提交。在此之后,我将假设您对两个repos都没有写权限。
使用git fetch从一个repos下载更改,例如git fetch upstream master,然后查看提交与git log,然后使用git rebase以安全的方式合并更改。
有关更多信息,请参考Git官方书,但是在阅读了第三章之后,您应该会很好。
发布于 2017-09-06 14:49:49
有三种使用多个git遥控器的一般情况,如何处理取决于您需要哪种情况:
如前所述,处理事情取决于您所处的情况。实际上,最简单的情况(我认为是您对问题的描述)是案例2,实际上,管理只包括在推送更新时确保推送到两个存储库(git要求您显式地推送到每个远程)。案例3也很简单,当您发布一个版本时,只需标记它并将其推送到两个存储库,但是只有当您没有发布某个版本时,才会推到您的开发存储库。
案例1虽然最常见,但却是最复杂的,因为它所涉及的不仅仅是推和拉命令。唯一的情况是,当有一个上游更新时,第二个远程就会起作用,此时您需要在此基础上重新建立(或合并)本地分支(这取决于您的本地工作流)。
另外,你可能对官方的吉特书感兴趣,它在解释事物方面做得很好。关于“分布式Git”的章节可能是这个问题最相关的一节,但我绝对建议阅读整个内容,因为理解工作流需要很好地理解Git如何进行源代码管理。
https://unix.stackexchange.com/questions/390599
复制相似问题