git-ps-rs icon indicating copy to clipboard operation
git-ps-rs copied to clipboard

Add command to backup the stack to the remote in case machine failure

Open drewdeponte opened this issue 3 years ago • 9 comments

@chillbrodev mentioned in chat

had a random idea of a backup feature where you could use gps backup and it creates remote branches of all your patches even if there are patch dependencies. I do this when Im about to travel and have a few loose patches for those “just in case fears”.

Maybe this just becomes in option on sync -all for sync all or something.

I am not sure how valuable I really feel this command is.

drewdeponte avatar Apr 30 '22 00:04 drewdeponte

The value is quite small and niche. Its more of a feature that is rarely used though I see how it could be abused to create patch PRs with dependencies. CI would fail the PR since it couldn't build it and maybe it makes sense to inject the word "BACKUP" or something into the commit. Thinking out loud here.

chillbrodev avatar May 02 '22 16:05 chillbrodev

Well if there are conflicts in the cherry-picking it wouldn't be possible to sync the patch. Syncing only works for patches that are independent enough that they can be cherry-picked.

drewdeponte avatar May 02 '22 16:05 drewdeponte

If you want to back your stack up, it might make more sense to create a stack specific branch and force pushes the stack up to it

drewdeponte avatar May 02 '22 16:05 drewdeponte

Ah this might be more what I am looking for. The Backup Branch would work. We can close this then.

chillbrodev avatar May 02 '22 17:05 chillbrodev

It still might be nice to have this to help hold the Patch Stack abstraction and make it so you don't have to think about the fact that it is a branch. Also I don't think it is totally straight forward how you would do it.

If we take the example of main as your local branch and it is a tracking branch of the upstream origin/main.

You wouldn't want to push main up to origin/main because that would effectively integrate all of the patches in your stack. Instead we would probably want to do the following.

  • create a new branch ps/stack-backups/main (or something similar) that points to the head commit of the local main branch
  • push the ps/stack-backups/main branch up to the remote associated with the stack, in this case origin so it would then have origin/ps/stack-backups/main

At this point the entire stack would be backed up.

Now we probably also need to think about uniqueness across users because once we push remote if two users do this they would overwrite each others branches. So the branches somehow need to have something user unique in the branch naming.

But I think in theory that would work and I think it is enough of a pain to have to do this manually with git that it would be nice to implement it.

drewdeponte avatar May 02 '22 17:05 drewdeponte

I think the biggest question in terms of implementation is figuring out where we get user unique identifier. I guess we could pull the user email out of the .gitconfig and hash it to get a unique identifier we can use in the branch name.

drewdeponte avatar May 02 '22 17:05 drewdeponte

so the branch naming would be something maybe like ps/stack-backups/<user-unique-hash>/main.

drewdeponte avatar May 02 '22 17:05 drewdeponte

Now that gps no longer has state tracking and it does pure state computation from the Git tree. This likely needs to be rethought.

drewdeponte avatar Oct 13 '23 18:10 drewdeponte

The goto solution for me is to branch and push to a remote. Especially if I need some patches on another matchine. gps could do this with say gpp bu which would create a patch series for the entire stack and push it to a special branch, say with time and date in the name.

Alizter avatar Oct 13 '23 23:10 Alizter