Is it OK to use `git push` to restore a remote repository? -


suppose have lost remote repository, because accidentally typed following command.

rm -rf ourrepo.git 

in order restore it, plan use 1 of top-voted answers earlier question.

however, observed none of solutions mentions following three-step strategy.

  1. use git init --bare recreate remote repository.
  2. set new remote git remote add origin <new repository url>.
  3. use git push origin master 1 of machines has up-to-date copy of repo

i have tried on toy respository , appears work, 1 of colleagues claims there problem without being able pinpoint why.

can either confirm or deny whether reasonable way restore lost remote?

no, there shouldn't wrong proposed strategy, , in fact typical way restore remote repository (though not way).

don't forget push tags along branches:

git push origin --tags --all 

that command push branches under .git/refs/heads/ , tags under .git/refs/tags/. if don't want push of branches, name each branch want push instead of using --all.

you'll want avoid using --mirror in case, because push all references under .git/refs/, include remote-tracking branches in local repo, don't need or want on remote.

alternatives

the other alternative using git push restore remote clone new remote repo --bare option:

git clone --bare <otherrepo> <newreponame> 

documentation


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -