0

I need to perform major operations on my git repository. I'm not yet sure that I will succeed, and I may need to use methods I'm not yet fully comfortable with. I expect to use a lot of merges, cherry-picks, --reset, rebases, and hopefully end up in a cleaner state. After I'm done I will push it upstream.

Since I'm not yet sure about the best strategy, I expect some of these operations will lead to dead ends.

No matter what I end up doing, I want to make sure I can always recover the current state for all branches, including possibly deleted local branches and commits.

I have previously used git reflog to undo premature merges and such, but I'm unsure if that can help me work with deleted branches. Most examples using reflog seems to apply to specific branches.

Can reflog help me, and if so, what exactly do I need to remember in order to be able to revert? Is there a better way?

pipe
  • 657
  • 10
  • 27
  • 4
    Back it up? which is as simple as pulling into another folder. If worst comes to worst just force push your backup copy back onto the server. The joy of GIT is that all copies of a repo are full copies – Liam Mar 06 '18 at 09:15
  • Possible duplicate of [Fully backup a git repo?](https://stackoverflow.com/questions/5578270/fully-backup-a-git-repo) – Liam Mar 06 '18 at 09:15
  • 2
    @Liam wouldn't using the `--mirror` option also be preferred? – evolutionxbox Mar 06 '18 at 09:31
  • Possibly but if it's only to rollback changes which is what the OP is talking about, it's not essential. A mirror is more useful if you think your going to totally bork the remote repo. But this is just moving some commits around. BTW what the OP is planning, doesn't sound like that big a deal (couple of cherry picks isn't going to do much harm), you could also reset your repo to a previous statue just using `reset` but a backup would be easier – Liam Mar 06 '18 at 09:47
  • Related [What's the difference between git clone --mirror and git clone --bare](https://stackoverflow.com/questions/3959924/whats-the-difference-between-git-clone-mirror-and-git-clone-bare) – Liam Mar 06 '18 at 09:49

0 Answers0