正确使用 git
过去几天我一直在阅读和尝试 Git,但我还有一件事似乎找不到好的信息。
我读到,使用 Git,通常会在每个开发人员的计算机上设置公共和私有存储库克隆,这样开发人员可以根据需要多次进行私有提交,然后仅在满意后才推送到公共存储库。的变化。
我想知道两件事:
1-我如何设置一个像上面这样的系统(同时使用集中类型方法(使用 --bare 创建的存储库)。2-
我希望能够做出尽可能多的提交我的私人存储库,因为我想要任何提交消息,并且当我将更改推送到公共存储库或裸存储库时,不会显示这些消息(或修订)。 IE。我希望我的公开变更能够通过一条消息一次性付清。
谢谢!
I have been reading up and trying Git for the last few days and I have one more thing that i can't seem to find good information on.
I read that with Git it's common to set up a public and a private repository clone on each developer's machine that way the developer can do private commits as many times as he/she wants and then only push to the public repository once they are satisfied with the changes.
I would like to know two things:
1-how do i set up a system such as the above (while using a centralized type approach (repository created with --bare).
2-I want to be able to make as many commits to my private repository as I want with any commit message and not have these messages (or revisions) show up when i push my changes to the public repository or the bare repository). Ie. i want my public changes to be committed as one lump sum with a single message.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git rebase 是你的朋友
这个问题的答案,what-are-your-favorite-git-features-or-tricks具体说说你的情况
git rebase is your friend
This answer to the question, what-are-your-favorite-git-features-or-tricks specifically talks about your situation
有几种方法可以设置 Git“中央”服务器,如 常见问题解答,主要通过 git-daemon、HTTP 或通过现有的 SSH 服务器(如果在 Linux 机器上,您可以通过适当设置 unix 组并授予组权限来共享存储库)。或者,您可以使用现有服务,例如 GitHub。
如果您想将多个本地提交作为单个提交推送,您可以使用 git merge 或 git rebase -i (交互式)“压缩”这些提交。我发现使用 git rebase -i 更容易。您需要为先前提交(您可能想要合并)提供哈希或标识符作为参数。然后,您将获得一个具有如下内容的编辑器:
然后,您可以编辑此文件以具有如下内容:
保存文件后,Git 将允许您编辑压缩为一条消息的提交的日志消息。实际上,您已将 0000001、a000002 和 dae3124 合并到“修复了大错误 1、2 和 3”中。例如。 (您也可以使用
fixup
。)您的日志将是:(当然,合并提交的结果哈希看起来与它来自的提交的哈希完全不同。)
一旦您完成了在本地完成后,您可以将该分支推送到远程公共存储库。
There are a few ways to set up a Git "central" server, as described in the FAQ, mainly via git-daemon, over HTTP or via an existing SSH server (if it's on a Linux box, you can share a repository by setting unix groups appropriately and giving group permissions). Alternatively, you can use existing services like GitHub.
If you want to push a number of local commits as a single commit, you can "squash" those commits, with
git merge
orgit rebase -i
(interactive). I find it easier to do withgit rebase -i
. You need to give a hash or identifier for a previous commit (from which you may want to merge) as an argument. Then, you'll get a editor with something like this:You can then edit this file to have something like this:
Once you save the file, Git will offer you to edit the log messages of the commits you squash into one message. Effectively, you'll have merged 0000001, a000002 and dae3124 into "Fixed big bugs 1, 2 and 3." for example. (You could use
fixup
too.) You log will then be:(Of course, the result hash of the merged commit will look nothing like the hashes of the commits it comes from.)
Once you've done that locally, you can push that branch to the remote public repository.
您好,
我建议您阅读这本关于 git 的免费书籍。 ProGit 书籍。它为 git 的所有功能打下了良好的基础。
为了解决您眼前的问题,我将引导您访问此页面
http://toolmantim.com/thoughts/setting_up_a_new_remote_git_repository< /a>
我在工作中使用这个过程。很棒的工作流程。我推荐它。
希望这有帮助。
Greetings,
I recommend reading this free book on git. ProGit book. It gives a very good grounding in all git's functions.
To solve your immediate problem, I'll direct you to this page
http://toolmantim.com/thoughts/setting_up_a_new_remote_git_repository
I use this process in work. Great workflow. I recommend it.
Hope this helps.