Skip to contentSkip to conversation

Advice regarding inherited git repository

DISCUSSION Jeff King 2 participants 2 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jeff King

author
#1 lore raw
Quoted 10 lines · Danielle

I inherited a web site and a git repository. the git repository is cloned to the website and a sandbox website (two clones). No commits have been done in more than 6 months. The main site has been updated a lot of times, the sandbox has lots of test and exploratory code. To bring things up to date, I thought of staging and committing all the files in the main site and pushing to the remote repository, and then fetching into the sandbox clone and merging what is needed (which will be sooo not trivial). Does this make sense? Or would it be better to create a sandbox branch somehow? I'm used to working with SVN, no real git experience, so I would appreciate any advice on how to manage this.

You probably should create a sandbox branch, for your own sanity. Because git is distributed, each separate repository is implicitly a branch. So if you did something like:

1. Commit all the changes on the main site to "master". Push the result to some common remote.

2. Commit all the changes in the sandbox to its "master". Do _not_ push to the remote.

3. Pull the changes from the remote into the sandbox. If they're worth adding to the main site, push them up. If not, leave them there.

That works; "master" in the sandbox has the experimental changes, but you don't have to push them anywhere. However, you are one accidental "git push" away from sending all of those experimental features to your remote "master". So it's easy enough to make step 1.5 "git checkout -b sandbox-cruft" in the sandbox repository, so git knows not to ever push it to "master".

In general, I'd also say you may benefit from splitting the changes in each repository into as many separate logical commits as you can (and possibly even to separate topic branches that you can merge independently). Given that you inherited this, that's _probably_ too much work. But if you do want to try it, I recommend "git add -p" for picking out individual hunks.

-Peff

#2 lore raw
Quoted 11 lines

You probably should create a sandbox branch, for your own sanity. Because git is distributed, each separate repository is implicitly a branch. So if you did something like:

1. Commit all the changes on the main site to "master". Push the result to some common remote.

2. Commit all the changes in the sandbox to its "master". Do _not_ push to the remote.

3. Pull the changes from the remote into the sandbox. If they're

worth

Quoted 5 lines

adding to the main site, push them up. If not, leave them there.

That works; "master" in the sandbox has the experimental changes, but you don't have to push them anywhere. However, you are one accidental "git push" away from sending all of those experimental features to

your

Quoted 2 lines

remote "master". So it's easy enough to make step 1.5 "git checkout -b sandbox-cruft" in the sandbox repository, so git knows not to ever

push

Quoted 11 lines

it to "master".

In general, I'd also say you may benefit from splitting the changes in each repository into as many separate logical commits as you can (and possibly even to separate topic branches that you can merge independently). Given that you inherited this, that's _probably_ too much work. But if you do want to try it, I recommend "git add -p" for picking out individual hunks.

-Peff

Thanks for answering!

I've done the above, but it caused some problems, some of which I haven't solved yet. What I have now is a master branch with the site in both repositories; and in the sandbox an additional devel branch with the changes done. I want to split the devel branch into the actual features being explored, and then merge each into master and push when done. The main trouble with that seems to be the settings.php file, which should be backed up but certainly shouldn't go from one site to another. Removing it from the repository caused some problems, even when keeping a local cache for some reason (it got lost when switching branches and gave me a bad moment until I figured it out). Any suggestions?

Add -p will certainly help in the feature branches, thanks for suggesting it!