How do you backup a Git repository?

122 Views Asked by At

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

2

There are 2 best solutions below

3
On BEST ANSWER

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.

0
On

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.