GithubHelp home page GithubHelp logo

kiprasmel / git-backup Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 67 KB

git-backup — like git stash, but remotely

License: GNU General Public License v2.0

Shell 72.10% Roff 21.62% Makefile 6.28%
git-backup in case of fire backup uncommited changes git

git-backup's Introduction

git-backup

In case of fire, use git-backup 🔥

git-backup is literally like git stash, but it makes stashes available on the remote for later use!

Installing

yay -S git-backup-git
  • From source:
git clone https://github.com/sarpik/git-backup.git
# or:  git clone [email protected]:sarpik/git-backup.git

cd git-backup

make install

Usage

cd some-git-repo/
git-backup

and later, if you want to apply the backup:

cd some-git-repo/
git stash apply <branch-name>

For ease of use, you could create a git alias for git-backup:

git config --global alias.backup "!git-backup"
git config --global alias.bp     "!git-backup" # extra quick backups 💦💦

and then use it by just running git backup.

Manual

See git-backup(1) (man git-backup or git-backup -m).

License

GPL-2.0 - same as git

git-backup's People

Contributors

kiprasmel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

git-backup's Issues

Create `delete backup` functionality

Task

  • Create a function which delete backups
    • Figure out how we want to display current backups so that we can
      • select one or multiple of them
    • One of them
    • Multiple
    • All
    • Make it work with remote backups (git push origin :branch-name)

Create `list backups` functionality

Task

  • Create a function which would list backups

    • Local backups
    • Remote backups
    • Both
    • Decide which backups should be listed by default
  • Implement an option to activate this function

    • think of a good name
    • handle in the script
    • update docs
      • raw
      • manual page
  • Make it extendable for other commands (see #4 & #5)

    • Make a single or multiple backups selectable (probably in interactive mode, something like git rebase -i)

Future

  • Display which ones can be backed up (to where HEAD points to, checking if the changes could apply without conflicts (check by commits/refs/whatever-works, if possible, to avoid having to test every backup))

Create `restore from backup` functionality

Task

  • Create a function which would restore changes from

    • XYZ backup

      • list backups - #6
        • select one to restore from
    • latest backup

      • Identify the latest backup (probably by the unix date timestamp we add to the branch name) (create as separate function since it'd be needed for other stuff too)
  • implement an option to activate this function

    • think of a good name
    • handle in the script
    • update docs
      • raw
      • manual page

Update README.md

Task

Update README.md with

  • description
  • installation info (preferably, using Makefile with make - see #1)
  • installation info for arch users (yay -S git-backup once #2 is done)

Better handle errors with bash equivalent of try/catch/finally

{
	do_stuff
	doSomeMoreStuff
} || {
	check_for_error_1 && handle_error_1
	checkForError2 && handleError2
}

This will be useful in restoring the git stash, independent of either a failure or success.
This will probable require a finally thingie.
Or maybe consider wrapping the function up? Maybe?

Create `Makefile`

Task

Create a Makefile that would

  • install the script in the appropriate /usr location - 7b2a6f0
    • re-search the proper /usr location
  • Update README - 3021bef
  • install & gzip the manual page (git-backup(1)) (why gzip?)

Notes

probably use install & gzip utils.

maaaaybe consider windows? lmao normies

High priority, since the user has to manually add the script to his path or the appropriate /usr location.

Same with the manual page. And the -m option won't work since the manual page is not provided.

Running in untracked directory will create the backup (stash), but won't pop it back

There's some bad sh1t happening if you run git-backup in an untracked directory.

I don't know if this also happens with just regular git stash -u (probably?)

I need to investigate more (I just wasted an hour+ trying to recover; I succeeded, but boy was this stressful).

What helped me recover was:

  1. checking my shell history - when was the last time I ran git-backup
  2. going through git reflog --all and finding a commit that has a date very similar to the one found in the shell's history. Mine was identical.
  3. git stash apply <COMMIT-ISH>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.