Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a local repository with a toy project that has turned out to be more serious than I had thought. So from a single development branch where I have carelessly committed, I have started to use branches kind of like in the famous http://nvie.com/posts/a-successful-git-branching-model/

I would now like to have a "central" remote repository that I can push my develop and master tree.

The first issue is: how do I do this. Do I initialize an empty repository on my server and reference to this repository as the remote origin in my local repository?

Do I have to create the branches in the remote repository beforehand or is it enough just to push them?

Secondly the first commits in my local repository are really awkward, so I would like to cumulate a lot of those early commits into one, either in the way of --no-ff or as I understand to squash them.

As I understand, this is only working with an intermediate branch. i.e. right now I have 2 branches "develop" and "master" in my local repository. I came up with two ideas how to "change history"

I create two branches develop-squashed and master-squashed. Rebase my original branches to those while squashing commits I want to loose. Upon having -squashed branches being equivalent with the original master and develop branches, I can delete the original ones and "rename" the *-squashed branches to master and develop.

Finally I can push master and develop into the remote repository.

  • Is that the way to go?

  • How can I make sure that by rebasing, both branches master and develop both have the same history up to the point when I started to follow the "successful git branching model"? (They have the same history up to that point at the moment).

share|improve this question

1 Answer 1

up vote 7 down vote accepted
  1. You have to first clean up the history, than create the central repository on server. Because once you publish the history, you won't be able to get it back.
  2. If the branches have common history throughout the period you want to modify, than you will only have one "*-squashed" branch. Having develop only makes sense since the point it actually differs from master.
  3. Have a look at the git filter-branch command. It should be able to do all the rebasing for you easily (as far as anything involving filter-branch can be called easy, but it will save you a lot of work in any case). The operation you'll want to do is basically simple; just for the first commit you want to keep replace the parent with the cleaned up one.
  4. I would probably not bother unless there is anything that you either can't legally publish or is really very very embarrassing as somebody would have to have a lot of free time to actually look at the early history.
  5. Just initialize empty repository on server, add it as remote and push the branches and tags, yes.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.