Git仅执行一次提交 [英] Git pull just one commit
问题描述
实际上git存储库和本地文件完全相同.
但是另一个网站距离5次提交还很遥远,所以我没有抽空,我也不想这样做.
所以现在我要在本地文件中进行一些更改,然后将其推送到git存储库的新提交中,然后只能拉一个提交而不是其他所有提交...我可以这样做吗? /p>
我什至不想删除此处的提交,只是我希望能够提取1个提交,希望您能为我提供帮助
如果您要提交一个提交,则可以简单地将其重置"为该提交.
git reset --hard <commit>
您还可以从该提交中创建一个新分支 foo ,并将该分支仅拉到您的新环境中.这将有助于维护您的代码库,因为您可以继续在原始分支上工作,而不必考虑影响新站点.
git checkout -b foo
这是简写
git branch foo
git checkout foo
然后您可以使用
将该分支拉到任何计算机上git clone -b *foo* http//dude@:bitbucket.org
或类似的
git clone -b *foo* ssh://git@bitbucket.org/path/to/repo.git
Actually the git repository and local files are exactly the same.
But the other website is far away from 5 commits, so I haven't pull in a while and I don't want to do it neither.
So now I wanna do some change in my local files and then push that into a new commit to git repository, THEN only be able to PULL that one commit and not all the others ... can I do this??
I don't even want to delete the commits there, just I want to be able to pull 1 commit, I hope you can help me
If you want to pull one commit, you can simply 'reset' to that commit..
git reset --hard <commit>
You could also make a new branch foo off that commit and pull only that branch down to your new environment. This will help maintain your codebase as you can continue to work on your original branch without having to think about affecting the new site.
git checkout -b foo
this is shorthand for
git branch foo
git checkout foo
You can then pull that branch onto whatever machine with
git clone -b *foo* http//dude@:bitbucket.org
or something like
git clone -b *foo* ssh://git@bitbucket.org/path/to/repo.git
这篇关于Git仅执行一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!