[英]Git pull from another repository without history
I'm here because : I try to connect my repository to another in order to keep "up to date" but I'm trying not to pull the whole history of the other repo... 我在这里是因为:我试图将我的存储库连接到另一个存储库以保持“最新”,但我试图不拉动其他存储库的整个历史...
To explain, I use Laravel 5 ( https://github.com/laravel/laravel ) and I have created my own master (which is a fork of laravel/v5.0.1) to customize some things inside (like a css framework, some generic layouts, etc.) -> call it "azurky-repo/master" 为了解释,我使用Laravel 5( https://github.com/laravel/laravel )并创建了我自己的master(这是laravel / v5.0.1的一个分支)来自定义内部的一些东西(比如一个css框架,一些通用布局等) - >称之为“azurky-repo / master”
And now I feel like updating my repository with lastest commits of laravel/master but each time I pull from laravel/master, my "git log" is full of commits (about 4400) and I don't want this. 现在我想用最新的laravel / master提交来更新我的存储库,但每次我从laravel / master中提取时,我的“git log”都会提交(大约4400)并且我不想要这个。 (I'm a kind of maniac guy who wants a clean repository and a lot of control over everything ^^) . (我是一个疯子,他想要一个干净的存储库,并且对所有事情都有很多控制权^^) 。
In an ideal world, I would like to update only the files and then just make one commit with a message like 'Update from Laravel/master' . 在一个理想的世界中,我想只更新文件 ,然后只使用“从Laravel / master更新”这样的消息进行一次提交 。 Without any other extra history entry or refs that I don't need at all. 没有任何其他额外的历史记录条目或参考,我根本不需要。
Tried without success : 尝试没有成功:
git pull --depth 1 laravel master
I still have an extra history entry... (the last laravel/master commit message and didn't succeed in amending... maybe missed something) 我还有一个额外的历史记录条目...(最后一个laravel / master提交消息,并没有成功修改...可能错过了一些东西)
Someone has an idea (or am I the only mad guy to try a thing like this..)? 有人有想法(或者我是唯一一个尝试这样的事情的疯子......)?
PS : PS:
To clarify, I would like to have the same result as if I : 为了澄清,我希望得到与以下相同的结果:
The matter is in fact I'm not masochist and don't want to bypass the merging ability of git... ^^ 事实上,我不是受虐狂,也不想绕过git的合并能力...... ^^
So I feel like having, finally, this history : 所以我觉得最后有这段历史:
In place of : 取代:
Do you see what I hope ? 你看到了我的希望吗?
Finally got it ! 终于明白了!
The answer is just a simple : 答案很简单:
git reset HEAD
Sorry I'm really new to git so I found the solution this afternoon after reading questions about this kind of subjects. 对不起我是git的新手所以今天下午我在阅读了有关此类主题的问题后找到了解决方案。 Didn't understood everything about indexes, now it's better =) 没有理解索引的一切,现在它更好=)
So from beginning I have a fresh repo with just an initial commit : 所以从一开始我就有一个新的回购只有一个初始提交:
git clone git@mygitserver:myuser/myrepo
git log
commit 1
Initial commit - Laravel v5.0.1
Then I pull from laravel/master 然后我从laravel / master拉出来
git remote add laravel https://github.com/laravel/laravel.git
git pull laravel master
git reset HEAD
git add --all
git commit -m 'Update from laravel/master'
git log
commit 2
Update from laravel/master
commit 1
Initial commit - Laravel v5.0.1
That seems OK, then I make an other modif. 那似乎没问题,然后我做了另一个修改。 to to be sure : 要确定:
git rm -rf resources/assets/less/
git add --all
git commit -m 'Suppression de bootstrap'
git log
commit 3
Suppression de bootstrap
commit 2
Update from laravel/master
commit 1
Initial commit - Laravel v5.0.1
NB : I write commit 1/2/3 to simplify of course 注意:我写提交1/2/3以简化当然
And then to be extra-sure : 然后要确定:
git push origin master
And check on the repository web page 并检查存储库网页
http://i.stack.imgur.com/7XMzb.jpg (sorry haven't the right to put the img) http://i.stack.imgur.com/7XMzb.jpg (抱歉没有权利把img)
That's OK for me =) 那对我来说没关系=)
Finally I like the way git works =) 最后我喜欢git的工作方式=)
This may be a bit of a "hack" way to do it. 这可能是一种“黑客”方式。 But, you could just git pull from that main repo, then rm the .git files in the folder, then git init
and then git push -force
to your repo version each time you wish to pull from the main repo. 但是,您可以从主要仓库中获取git init
,然后在文件夹中输入.git文件,然后git init
,然后在每次希望从主仓库中提取时,将git push -force
到您的仓库版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.