Archer
Archer

Reputation: 189

git server recovery from local repo

My git server and all repositories were accidentally broken, and I'm trying to restore everything back to normal. However no matter how I tried, some of the remote branches just don't restore.

My situation describes below:

git branch -a

* master
  branch_1
  branch_2
  branch_3
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch_1
  remotes/origin/branch_2
  remotes/origin/branch_3
  remotes/origin/branch_4
  remotes/origin/branch_5

I local repo has some branches created after cloning from server. And rest of them weren't being touched. But the records were all in the local repo. (able to be switched)

And I was trying to push everything to new server. But all records under "remotes/*" weren't be able to pushed to new server.

Any idea how to restore everything to new server?

Upvotes: 1

Views: 367

Answers (1)

VonC
VonC

Reputation: 1324188

All records under remotes are not supposed to be pushed: they are remote tracking branch, keeping track of what you have pulled before.

Pushing only your local branch should be enough.

For the remote tracking branches which don't have a local branch, you can create said local branches for each remote one, and push them as well.
See "Track all remote git branches as local branches".
Or (simpler):

for remote in `git branch -r | grep -v /HEAD`; do git checkout --track $remote ; done

Upvotes: 1

Related Questions