Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 5 Next »

This is a work in process. I have a tendency to put as much info as I can. Some stuff could be wrong please fix. I don't know git well.

How do avoid? Before you push know exactly what that push is doing. Test it in contained lab environment if you don't know what it does. Use Alexander's git wrapper script to interact with https://github.com/rchain/rchain


Git - What to do when an unwanted deletes happen in a remote repo?

  • Try and restore branches from previously open pull requests in github web interface. Go to Pull Requests(tab) and then specific pull request. There are two buttons to click on Open pull request(button) at bottom of page.  And there will be a restore PR button by 
  • resubmit from local

Note: If you pull and see that your stuff is gone revert to previous commit and push that up to your branch


Example:

Wanted to just push my working local in entirety to my github repo. Did git push --mirror. and it ended up deleting stuff from upstream.

In this case, noted at bottom of this read, a push was accidentally deleting branches.

Commands and output:

root@maximus:~/code/rchain# git remote set-url --push origin https://github.com/jeremybusk/mirrored-test
root@maximus:~/code/rchain# git remote -v
origin git@github.com:jeremybusk/rchain (fetch)
origin https://github.com/jeremybusk/mirrored-test (push)
upstream git@github.com:rchain/rchain (fetch)
upstream git@github.com:rchain/rchain (push)
root@maximus:~/code/rchain# git push --mirror
Counting objects: 7, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 801 bytes | 0 bytes/s, done.
Total 7 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/dev.
remote: error: Cannot delete a protected branch
To git@github.com:rchain/rchain
- [deleted] dev-eitan&kyle-spatial
- [deleted] dev-eitan-docs
- [deleted] dev-eitan-readmes
- [deleted] dev-griff-core-88
- [deleted] dev-kent-build-readme
- [deleted] dev-kent-ubuntu-14.04
- [deleted] revert-70-dev-kent-build-readme
- [deleted] spatial
* [new branch] OPS-35 -> OPS-35
* [new branch] origin/HEAD -> origin/HEAD
* [new branch] origin/OPS-35 -> origin/OPS-35
* [new branch] origin/dev -> origin/dev
* [new branch] origin/dev-eitan&kyle-spatial -> origin/dev-eitan&kyle-spatial
* [new branch] origin/dev-eitan-docs -> origin/dev-eitan-docs
* [new branch] origin/dev-eitan-readmes -> origin/dev-eitan-readmes
* [new branch] origin/dev-griff-core-88 -> origin/dev-griff-core-88
* [new branch] origin/dev-kent-build-readme -> origin/dev-kent-build-readme
* [new branch] origin/dev-kent-ubuntu-14.04 -> origin/dev-kent-ubuntu-14.04
* [new branch] origin/master -> origin/master
* [new branch] origin/revert-70-dev-kent-build-readme -> origin/revert-70-dev-kent-build-readme
* [new branch] origin/spatial -> origin/spatial
* [new branch] upstream/dev -> upstream/dev
* [new branch] upstream/dev-eitan&kyle-spatial -> upstream/dev-eitan&kyle-spatial
* [new branch] upstream/dev-eitan-docs -> upstream/dev-eitan-docs
* [new branch] upstream/dev-eitan-readmes -> upstream/dev-eitan-readmes
* [new branch] upstream/dev-griff-core-88 -> upstream/dev-griff-core-88
* [new branch] upstream/dev-kent-build-readme -> upstream/dev-kent-build-readme
* [new branch] upstream/dev-kent-ubuntu-14.04 -> upstream/dev-kent-ubuntu-14.04
* [new branch] upstream/master -> upstream/master
* [new branch] upstream/revert-70-dev-kent-build-readme -> upstream/revert-70-dev-kent-build-readme
* [new branch] upstream/spatial -> upstream/spatial
! [remote rejected] dev (protected branch hook declined)
error: failed to push some refs to 'git@github.com:rchain/rchain'
root@maximus:~/code/rchain# 

Noooooo!



Other options????

So one might look at git reflog and git revert but that may make things worse especially on public repos. Git revert really just creates a commit the exact opposite of what you just did depending.

A better option would be ...

git reflog and git revert are options sometimes but not here.

https://stackoverflow.com/questions/3640764/can-i-recover-a-branch-after-its-deletion-in-git

https://git-scm.com/docs/git-revert

https://github.com/blog/2019-how-to-undo-almost-anything-with-git

  • No labels