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 project folder that has multiple duplicate files that are named slightly differently to create "backups". So I have "file1.txt" and "file1 backup.txt". Is there a preferred method to capture the old history when I make the folder into a git repository?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

With out a lot of messing about, the simplest option is to just commit the full project folder as the first commit, then delete all of the backup files and finally commit your 'cleaned up' copy. That way you can access the copies of the old files any time you want, but they don't normally clutter up your working directory.

If you really want to try and reconstruct your history you might try using some of the techniques from Charles Bailey's Lightning talk at this years ACCU Conference:

  • Massaging Hunks: The Awesome Power of git add -p (p89).
share|improve this answer
    
This sounds like a great plan. Thanks –  Matt Phillips Jul 15 '11 at 14:16
add comment

Don't put them in at all! I don't know the exact way in Git, but in SVN you just don't add them to the repository. With a version control system you don't need another history - it just adds complexity.

You should alway commit to source control as soon as possible. Generally this is as soon as you have working code. The more often you commit, the less likely those other history files will be needed.

share|improve this answer
    
Yes I am well aware of committing to source as early as possible. Unfortunately I received these projects from someone who doesn't use source control or understand it. So I'm trying to get it into Git for my own sake. If it was me from the beginning this wouldn't be an issue –  Matt Phillips Jul 15 '11 at 14:16
    
This doesn't quite answer the question. The OP has a non-versioned folder with several files representing different versions of the same document. Using Git, he wants to keep the different versions, and therefore the history of the document, without having separate files. If he doesn't put them in at all he loses the existing history when he converts to Git. You're right that you should always use source control, though; at the very least, you should do so the moment you find yourself creating "file1 backup.txt". –  Ant Jul 15 '11 at 14:17
add comment

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.