0

First let me begin by saying what I want to do, then what seems not to work.

I have a project A, it sits in /local/projects/A.
I want to copy the git repository over to another directory /local/backup/A.

I also want to copy the git repo to /local/sandbox/A/aspect1, /local/sandbox/A/aspect2 ...

I want the copy to be complete.
By that I mean that if /local/projects/A gets accidentally deleted, I want to be able to take /local/backup/A ( or one of the other copies ) and copy it back to /local/projects/A and be able to continue ( after adding any pushes that happened since the last backup ) as though nothing happened.

Preferably I use git to do this rather then cp/rsync/generic copying program.

Now what I've been doing that hasn't worked.

I cd into /local/backup/A and do a:

 git clone /local/project/A. 

The problem is that I have two branches in my test project: master and b1. After cloning into /local/backup/A and doing git branch I see only one branch b1.

So how do I make sure that I copy everything that is in the original?

One fear I have is to have a process where it looks like I've got everything ( say both branches ) and then when it's too late, I discover that I've missed copying something.

I've seen some articles on the net, but it seems like they focus more on the copying remote repositories not local repositories and I get confused by some stuff in those descriptions.

Stian Skjelstad
  • 2,277
  • 1
  • 9
  • 19
TLOlczyk
  • 443
  • 3
  • 11
  • When using Git I don't believe you need to do such backing up. Just push your repo to the remote (e.g. GitHub or BitBucket), and forget about it. Enterprise Git repos will themselves be backed up. – Tim Biegeleisen Apr 16 '16 at 13:54
  • Regardless of how you manage to get the other branches, make sure to use `--no-hardlinks`. Otherwise, `git` will use hard links to save space. – Zeta Apr 16 '16 at 13:54

1 Answers1

0

So how do I make sure that I copy everything that is in the original?

Once you clone or copy your .git folder to another location you have a full copy of your repository (all the commits of all branches).

If you are working on the repository (or on any copy) each copy has its own HEAD. To understand what is HEAD and what does it means click on the link and read all about it.

In your case you have a single branch which you are using right now so you will have only that branch checked out.

If you wish to see the list of all your branches (local + remote):

git branch -a

Note

Once you commit and push all your changes to the remote repository this is your backup.
Why do you need other backups as well?

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167