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!
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 mergeorgit 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
fixuptoo.) 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.