0

I have studied posts on StackOverflow about pushing and pulling, but here is a "greenhorn" question as a failover in case I make a mistake (which of course for me is impossible..).

The question is, if I copy the repo folder locally, and then remove both the .gitignore file and the .git folder from the copy, have I removed git's awareness of that copy folder entirely?

I am hoping the answer is yes, and again, this is just a measure until I'm totally secure between pushes and pulls from multiple branches

Samuel Fullman
  • 1,262
  • 1
  • 15
  • 20
  • As [@watson points out in his answer](http://stackoverflow.com/a/23228900/456814), making a manual copy basically creates two separate repos that won't be "aware" of each other (in this case). If all you wanted to do was a backup, then a simple `cp -r` is all you need, you don't need to go delete the `.git` folder. If you delete `.git`, then you don't really a backup, because doing that basically deletes the history for your repo, so you're actually losing work. Is that really what you wanted to do? –  Apr 23 '14 at 05:50
  • See also [Backup of github repo](http://stackoverflow.com/q/1251713/456814). –  Apr 23 '14 at 06:01

2 Answers2

2

If you make a copy of a repo folder, neither the original or the copy will be aware of each other, even while the .git and .gitignore folder / file are present.

In most cases (excluding submodules) the only knowledge a particular repo folder will have of other repos, exists as its remote, origin or otherwise.

dezman
  • 18,087
  • 10
  • 53
  • 91
0

The answer is yes, this would not be treated as a git repository if the .git directory is not present. Although, there is a nice stash command inside git itself that would take you local changes and store them within itself, so that you can come back to them later.

Nikhil Gupta
  • 1,708
  • 1
  • 23
  • 38
  • @Nikhil_Gupta, thank you, and as a note, I appreciate the fact that you actually answered the question I posted vs. saying "learn stash and add more to your workload" - I will look at that though I haven't see it in the gitbox options on the mac, but in the mean time feel safer doing pushes and pulls – Samuel Fullman Apr 22 '14 at 20:03
  • Deleting the `.git` folder basically throws away the history of the repository, so it's not a real backup, and is actually a pretty dangerous thing to do. –  Apr 23 '14 at 05:51
  • That's what Samuel wants. He is trying to backup the entire repo on a different directory and remove .Git from there. – Nikhil Gupta Apr 23 '14 at 06:51