Compare commits

...

43 commits
v5.3 ... master

Author SHA1 Message Date
Bhupesh-V 38b7be7335 🔖 release 5.9
Some checks failed
build / Linux Test (push) Has been cancelled
2025-04-13 14:41:16 +05:30
Bhupesh-V 2b0936d813 add support for recovering multiple uncommited deleted files (#79) 2025-04-13 14:40:43 +05:30
allcontributors[bot] fc4e473fa2
docs: add luxxmr as a contributor for doc (#78)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2025-03-18 14:12:13 +05:30
luxxmr 43c205e315
README.md file update to include the "git-undo" command conflict with git-extra. (#77) 2025-03-18 14:11:17 +05:30
Bhupesh Varshney 019646b1ed
add docker pulls 2024-02-07 14:42:34 +05:30
Bhupesh-V ab99ea6110 🐛 my bad, forgot grep (used by undo git rm) 2024-02-06 23:41:00 +05:30
Bhupesh Varshney 8f6e7218da
add package status 2024-02-05 13:47:04 +05:30
Bhupesh-V 0295f27059 🔖 release 5.8 ready 2024-02-03 12:07:32 +05:30
Bhupesh Varshney 75b2cd6e9e
add dockerfile (#72) 2024-02-03 11:57:47 +05:30
Bhupesh Varshney 4cf49f843a
grammar fixes 2024-02-03 11:47:03 +05:30
Bhupesh Varshney 5d6b3688f2
🚸 improve support for running ugit via docker (#68) (#69)
- don't update ugit inside docker
- instead of opening a browser, print the guide URL
- remove usage of basename on help text (#66)
2024-02-02 23:11:16 +05:30
allcontributors[bot] 2489a568cb
docs: add T-Joseph-Kim as a contributor for code (#71)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2024-02-02 23:07:16 +05:30
Taebok Joseph Kim d76d376c30
Removed usage of HEREDOCS and replaced with preferred "printf" statements for printing "--help" text. (#70)
---------

Co-authored-by: Bhupesh Varshney <varshneybhupesh@gmail.com>
2024-02-02 23:05:06 +05:30
Bhupesh-V 7be63fc4c5 🔖 release v5.7 2023-10-20 12:06:19 +05:30
Bhupesh Varshney 1f4a0c57c2
Merge pull request #65 from wrecklass/master
Sort tags by refname in fzf list. Issue #64
2023-10-20 12:04:50 +05:30
Stephen Martin 40289fd584 Sort tags by refname in fzf list. Issue #64 2023-10-18 22:58:45 -06:00
Bhupesh-V 21f96ec035 🔖 release 5.6 2023-05-27 16:01:23 +05:30
Bhupesh Varshney 6db2f6b3d9
Merge pull request #61 from nalin-singh/feature
Added empty list check
2023-05-27 15:59:30 +05:30
Nalin Singh b959579bee Suggestion Resolved 2023-05-26 12:56:44 +05:30
Nalin Singh 7c3a283e43 Added empty list check 2023-05-24 16:16:32 +05:30
Bhupesh-V 8ae45783d2 🔖 release 5.5 2023-03-27 17:27:24 +05:30
Bhupesh Varshney 7c81a3e32f
Merge pull request #60 from Bhupesh-V/all-contributors/add-dr41d45
docs: add dr41d45 as a contributor for code
2023-03-27 17:23:34 +05:30
allcontributors[bot] 44a45f3419
docs: update .all-contributorsrc [skip ci] 2023-03-27 11:53:24 +00:00
allcontributors[bot] d7afd0552a
docs: update README.md [skip ci] 2023-03-27 11:53:23 +00:00
Bhupesh Varshney e58ac52709
Merge pull request #59 from dr41d45/master
Update fzf version comparison to remove letters and parentheses
2023-03-27 17:21:38 +05:30
dr41d45 562dfe8a8a Fix fzf version comparison for --pointer option 2023-03-27 09:25:24 +03:00
dr41d45 19ed0d8c08 Update fzf version comparison to remove letters and parentheses 2023-02-24 16:00:35 +02:00
Bhupesh Varshney 59b1e4fe50
latest news 2022-10-31 10:44:36 +05:30
Bhupesh Varshney 76b4c96fbf
bump release no 2022-10-12 18:40:41 +05:30
Bhupesh Varshney 803ece4a10
Merge pull request #57 from Bhupesh-V/all-contributors/add-Theotime812
docs: add Theotime812 as a contributor for code, and bug
2022-10-09 11:53:23 +05:30
allcontributors[bot] 60928bad9f
docs: update .all-contributorsrc [skip ci] 2022-10-09 06:22:51 +00:00
allcontributors[bot] f845e84a8c
docs: update README.md [skip ci] 2022-10-09 06:22:50 +00:00
Bhupesh Varshney dd91afca46
Merge pull request #56 from Theotime812/master
Added support for fzf < 0.21.0
2022-10-09 11:52:05 +05:30
Théotime Maillarbaux 77b1f7f24a
Added double quotes around new variables when they're used 2022-10-08 01:58:18 +02:00
thmaillarb b5d650181a Added support for fzf < 0.21.0 2022-10-05 15:20:01 +02:00
Bhupesh-V 7fb08530fa update application id 2022-09-18 13:57:40 +05:30
Bhupesh Varshney 6d5fe5aa61
Merge pull request #54 from Bhupesh-V/all-contributors/add-RohitSingh107
add RohitSingh107 as a contributor
2022-09-18 13:44:19 +05:30
allcontributors[bot] 8fcf45c947
update .all-contributorsrc [skip ci] 2022-09-18 08:14:09 +00:00
allcontributors[bot] 60137bbb86
update README.md [skip ci] 2022-09-18 08:14:08 +00:00
Bhupesh Varshney 8bf1dec8ed
Merge pull request #53 from RohitSingh107/master
added flatpak
2022-09-18 13:43:12 +05:30
Rohit 1c698ca10b added flatpak 2022-09-08 22:30:09 +05:30
Bhupesh Varshney cd5960b2f4
Merge pull request #52 from thecesrom/fix/undo-initial-commit-printf-success
fix: `printf` command when undoing initial commit
2022-08-29 11:23:28 +05:30
César Román 78f3e559f3
fix: fix printf command when undoing initial commit 2022-08-27 17:08:49 -07:00
7 changed files with 286 additions and 59 deletions

View file

@ -90,6 +90,52 @@
"contributions": [
"doc"
]
},
{
"login": "RohitSingh107",
"name": "RohitSingh107",
"avatar_url": "https://avatars.githubusercontent.com/u/64142943?v=4",
"profile": "https://github.com/RohitSingh107",
"contributions": [
"platform"
]
},
{
"login": "Theotime812",
"name": "Théotime Maillarbaux",
"avatar_url": "https://avatars.githubusercontent.com/u/45947878?v=4",
"profile": "https://github.com/Theotime812",
"contributions": [
"code",
"bug"
]
},
{
"login": "dr41d45",
"name": "dr41d45",
"avatar_url": "https://avatars.githubusercontent.com/u/47773787?v=4",
"profile": "https://github.com/dr41d45",
"contributions": [
"code"
]
},
{
"login": "T-Joseph-Kim",
"name": "Taebok Joseph Kim",
"avatar_url": "https://avatars.githubusercontent.com/u/116681578?v=4",
"profile": "https://github.com/T-Joseph-Kim",
"contributions": [
"code"
]
},
{
"login": "luxxmr",
"name": "luxxmr",
"avatar_url": "https://avatars.githubusercontent.com/u/185298948?v=4",
"profile": "https://github.com/luxxmr",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
@ -97,5 +143,7 @@
"projectOwner": "Bhupesh-V",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true
"skipCi": true,
"commitConvention": "angular",
"commitType": "docs"
}

71
Dockerfile Normal file
View file

@ -0,0 +1,71 @@
FROM alpine:3.18 as ugit-ops
RUN apk add --no-cache \
bash \
coreutils \
git \
ncurses \
curl
# Download fzf binary from GitHub, pin to 0.46.0, ugit requires minimum 0.21.0
RUN curl -L -o fzf.tar.gz https://github.com/junegunn/fzf/releases/download/0.46.0/fzf-0.46.0-linux_amd64.tar.gz && \
tar -xzf fzf.tar.gz && \
mv fzf /usr/bin/
# Copy only the ugit script into the container at /app
COPY ugit .
# Set permissions and move the script to path
RUN chmod +x ugit && mv ugit /usr/bin/
# Second stage: Copy only necessary binaries and their dependencies
FROM scratch
LABEL description="Undo your last oopsie in git with ugit"
LABEL maintainer="Bhupesh Varshney <varshneybhupesh@gmail.com>"
COPY --from=ugit-ops /usr/bin/ugit /bin/
COPY --from=ugit-ops /usr/bin/git /usr/bin/
COPY --from=ugit-ops /usr/bin/fzf /usr/bin/
COPY --from=ugit-ops /usr/bin/tput /usr/bin/
COPY --from=ugit-ops /usr/bin/nl /usr/bin/
COPY --from=ugit-ops /usr/bin/awk /usr/bin/
COPY --from=ugit-ops /usr/bin/xargs /usr/bin/
COPY --from=ugit-ops /usr/bin/cut /usr/bin/
COPY --from=ugit-ops /usr/bin/tr /usr/bin/
COPY --from=ugit-ops /bin/bash /bin/
COPY --from=ugit-ops /bin/grep /bin/
# copy lib files
# COPY --from=ugit-ops /usr/lib/libncursesw* /usr/lib/
COPY --from=ugit-ops /usr/lib/libncursesw.so.6 /usr/lib/
# COPY --from=ugit-ops /usr/lib/libpcre* /usr/lib/
COPY --from=ugit-ops /usr/lib/libpcre2-8.so.0 /usr/lib/
# COPY --from=ugit-ops /usr/lib/libreadline* /usr/lib/
COPY --from=ugit-ops /usr/lib/libreadline.so.8 /usr/lib/
COPY --from=ugit-ops /lib/libacl.so.1 /lib/
COPY --from=ugit-ops /lib/libattr.so.1 /lib/
COPY --from=ugit-ops /lib/libc.musl-* /lib/
COPY --from=ugit-ops /lib/ld-musl-* /lib/
COPY --from=ugit-ops /lib/libutmps.so.0.1 /lib/
COPY --from=ugit-ops /lib/libskarnet.so.2.13 /lib/
COPY --from=ugit-ops /lib/libz.so.1 /lib/
# copy terminfo database
COPY --from=ugit-ops /etc/terminfo/x/xterm-256color /usr/share/terminfo/x/
# Gib me all the colors
ENV TERM=xterm-256color
# Let fzf know our deault shell
ENV SHELL=/bin/bash
# Let ugit know we are running in docker
ENV UGIT_RUNNING_IN_DOCKER=true
WORKDIR /app
# Run ugit when the container launches
ENTRYPOINT ["/bin/bash", "/bin/ugit"]

View file

@ -5,8 +5,8 @@
<a href="https://github.com/Bhupesh-V/ugit/actions/workflows/build.yml">
<img alt="build ugit" src="https://github.com/Bhupesh-V/ugit/actions/workflows/build.yml/badge.svg">
</a>
<a href="https://github.com/Bhupesh-V/ugit/blob/master/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/github/license/Bhupesh-V/ugit" target="_blank" />
<a href="https://hub.docker.com/r/bhupeshimself/ugit">
<img alt="Docker pulls" src="https://img.shields.io/docker/pulls/bhupeshimself/ugit?logo=docker" target="_blank" />
</a>
<img alt="total downloads (github + brew)" src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Bhupesh-V/6b7b8e8576bc1ca237bffd9a344672ab/raw/ugit-downloads.json">
<a href="">
@ -39,16 +39,16 @@ https://user-images.githubusercontent.com/34342551/121651071-d9fd1580-cab7-11eb-
## Why use `ugit`?
- You ran an accidental `git` command you wish to 'undo'.
- You accidentally ran a `git` command you wish to 'undo'.
- You want to save time by not searching for _how to undo ..._
- Your focus is on problems at hand and not on Git (avoid context switching)
- Because `ugit` is precise & uber cool !
- Your focus is on the problems at hand and not on Git (avoid context switching)
### [Motivations behind writing ugit 🙇‍♂️️](https://bhupesh-v.github.io/undo-your-last-git-mistake-with-ugit)
## What's in the box ?
## What's in the box?
`ugit`/`git-undo` supports undoing following operations, some are a WIP. If you know of any other operations that can be undone and is not in the list, make sure to raise an issue or make a quick PR 💛️
`ugit`/`git-undo` supports undoing the following operations, some are a WIP. If you know of any other operations that can be undone and are not in the list, make sure to raise an issue or make a quick PR 💛️
- [x] Undo `git commit`
- [x] Undo `git add`
@ -67,7 +67,7 @@ https://user-images.githubusercontent.com/34342551/121651071-d9fd1580-cab7-11eb-
- [ ] Undo `git rebase`
- [ ] Undo `git worktree remove` (recover deleted work-tree)
Contribute to the project by helping me with the above mentioned tasks.
Contribute to the project by helping me with the above-mentioned tasks.
If you have any other ideas/suggestions, do send them across. [**Hop in to ugit discussions 💬️**](https://github.com/Bhupesh-V/ugit/discussions/7)
@ -75,6 +75,7 @@ If you have any other ideas/suggestions, do send them across. [**Hop in to ugit
| When | What |
|:--------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 29 Oct, 2022 | ugit crossed 1k stars |
| 02 June, 2022 | [console.dev](https://console.dev/tools/) featured [ugit](https://twitter.com/bhupeshimself/status/1532714651842396161) |
| 18 May, 2022 | I gave a talk about the git tooling ecosystem & `git undo` in [Undo git, say whaat! - **GitHub India Constellation**, May 2022](https://youtu.be/jpR9BMFmh4Y?t=15240) |
| 12 May, 2021 | The [guide was **tweeted by GitHub**](https://twitter.com/github/status/1392207961355862018?s=20) (I was logging my research process there while building ugit) |
@ -82,11 +83,18 @@ If you have any other ideas/suggestions, do send them across. [**Hop in to ugit
## Community
- Alexander Alemayhu made a youtube tutorial on [Undoing Your Last Git Commit with Ugit](https://www.youtube.com/watch?v=nUnCgKb4tSc)
- Alexander Alemayhu made a YouTube tutorial on [Undoing Your Last Git Commit with Ugit](https://www.youtube.com/watch?v=nUnCgKb4tSc)
## Installation
[Try `ugit` via Docker](https://hub.docker.com/r/bhupeshimself/ugit):
```bash
docker pull bhupeshimself/ugit
docker run --rm -it -v $(pwd):/app bhupeshimself/ugit
```
### Prerequisites
**ugit** dependencies:
@ -96,6 +104,10 @@ If you have any other ideas/suggestions, do send them across. [**Hop in to ugit
- [**fzf**](https://github.com/junegunn/fzf) >= `0.21.0` - [Installation guide](https://github.com/junegunn/fzf#installation)
- GNU utils like `awk`, `grep`, `tput` etc
<br>
[![Packaging status](https://repology.org/badge/vertical-allrepos/ugit.svg)](https://repology.org/project/ugit/versions)
### Linux
@ -103,7 +115,7 @@ If you have any other ideas/suggestions, do send them across. [**Hop in to ugit
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
```
Or Arch Linux users can install [**ugit via AUR**](https://aur.archlinux.org/packages/ugit).
Arch Linux users can install [**ugit via AUR**](https://aur.archlinux.org/packages/ugit).
### Mac
@ -113,7 +125,7 @@ brew install ugit
### Windows
To use ugit on windows you need to install:
To use ugit on Windows you need to install:
1. Git Bash<br>
Git bash comes with git (if you have installed it on your machine then no need). To install git (preferably with scoop):
@ -180,6 +192,15 @@ If you're using [oh-my-zsh](github.com/robbyrussell/oh-my-zsh):
`source ~/.zshrc`
### Note on `git-undo` Command Conflict
If you have both `ugit` and `git-extras` (https://github.com/tj/git-extras) installed, be aware that both provide a `git-undo` command. This can lead to conflicts, as only one version of the command will be accessible at a time. To resolve this:
- **Using Homebrew**: Homebrew will notify you of the conflict during installation. You can choose to unlink the conflicting formula or use the --overwrite flag to force the link as follows:
`brew link --overwrite ugit`
- **Manual Installation**: Ensure that the `git-undo` command from the desired package is prioritized in your system's PATH.
## Please read ⚠️
@ -187,14 +208,14 @@ If you're using [oh-my-zsh](github.com/robbyrussell/oh-my-zsh):
Git comes with a garbage collector ([in case you didn't know](https://git-scm.com/docs/git-gc)) therefore undoing some commands will become impossible if the entries are deleted from the reflog.
One way to prevent this is to increase default time limits before the reflog entries expire.
Add these configuration in your global `.gitconfig` file:
Add these configurations in your global `.gitconfig` file:
```gitconfig
[gc]
# default 90 days
reflogExpire = 200
```
Used to set how long records in a branches reflog should be preserved.
Used to set how long records in a branch reflog should be preserved.
```gitconfig
[gc]
@ -234,19 +255,26 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/sharan-aithal"><img src="https://avatars.githubusercontent.com/u/32029982?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sharan Aithal</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Documentation">📖</a></td>
<td align="center"><a href="https://tabulate.tech"><img src="https://avatars.githubusercontent.com/u/58576759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tabulate</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=TabulateJarl8" title="Code">💻</a> <a href="#platform-TabulateJarl8" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="http://unixorn.github.io"><img src="https://avatars.githubusercontent.com/u/23920?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joe Block</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Documentation">📖</a> <a href="#plugin-unixorn" title="Plugin/utility libraries">🔌</a></td>
<td align="center"><a href="https://thecesrom.dev/"><img src="https://avatars.githubusercontent.com/u/19418023?v=4?s=100" width="100px;" alt=""/><br /><sub><b>César Román</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=thecesrom" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/issues?q=author%3Athecesrom" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/ibayramli2001"><img src="https://avatars.githubusercontent.com/u/43158991?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ilkin Bayramli</b></sub></a><br /><a href="#platform-ibayramli2001" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="https://github.com/kopalchakravarty"><img src="https://avatars.githubusercontent.com/u/31576619?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kopal Chakravarty</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=kopalchakravarty" title="Code">💻</a></td>
<td align="center"><a href="https://www.zorawarpurohit.com"><img src="https://avatars.githubusercontent.com/u/42845567?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zorawar Purohit</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=zora89" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://craftic.webflow.io"><img src="https://avatars.githubusercontent.com/u/38408670?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nalin Singh</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=nalin-singh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vinayaknayar"><img src="https://avatars.githubusercontent.com/u/98237998?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vinayaknayar</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=vinayaknayar" title="Documentation">📖</a></td>
</tr>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sharan-aithal"><img src="https://avatars.githubusercontent.com/u/32029982?v=4?s=100" width="100px;" alt="Sharan Aithal"/><br /><sub><b>Sharan Aithal</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://tabulate.tech"><img src="https://avatars.githubusercontent.com/u/58576759?v=4?s=100" width="100px;" alt="Tabulate"/><br /><sub><b>Tabulate</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=TabulateJarl8" title="Code">💻</a> <a href="#platform-TabulateJarl8" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://unixorn.github.io"><img src="https://avatars.githubusercontent.com/u/23920?v=4?s=100" width="100px;" alt="Joe Block"/><br /><sub><b>Joe Block</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Documentation">📖</a> <a href="#plugin-unixorn" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://thecesrom.dev/"><img src="https://avatars.githubusercontent.com/u/19418023?v=4?s=100" width="100px;" alt="César Román"/><br /><sub><b>César Román</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=thecesrom" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/issues?q=author%3Athecesrom" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ibayramli2001"><img src="https://avatars.githubusercontent.com/u/43158991?v=4?s=100" width="100px;" alt="Ilkin Bayramli"/><br /><sub><b>Ilkin Bayramli</b></sub></a><br /><a href="#platform-ibayramli2001" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kopalchakravarty"><img src="https://avatars.githubusercontent.com/u/31576619?v=4?s=100" width="100px;" alt="Kopal Chakravarty"/><br /><sub><b>Kopal Chakravarty</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=kopalchakravarty" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.zorawarpurohit.com"><img src="https://avatars.githubusercontent.com/u/42845567?v=4?s=100" width="100px;" alt="Zorawar Purohit"/><br /><sub><b>Zorawar Purohit</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=zora89" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://craftic.webflow.io"><img src="https://avatars.githubusercontent.com/u/38408670?v=4?s=100" width="100px;" alt="Nalin Singh"/><br /><sub><b>Nalin Singh</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=nalin-singh" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vinayaknayar"><img src="https://avatars.githubusercontent.com/u/98237998?v=4?s=100" width="100px;" alt="vinayaknayar"/><br /><sub><b>vinayaknayar</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=vinayaknayar" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/RohitSingh107"><img src="https://avatars.githubusercontent.com/u/64142943?v=4?s=100" width="100px;" alt="RohitSingh107"/><br /><sub><b>RohitSingh107</b></sub></a><br /><a href="#platform-RohitSingh107" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Theotime812"><img src="https://avatars.githubusercontent.com/u/45947878?v=4?s=100" width="100px;" alt="Théotime Maillarbaux"/><br /><sub><b>Théotime Maillarbaux</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=Theotime812" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/issues?q=author%3ATheotime812" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dr41d45"><img src="https://avatars.githubusercontent.com/u/47773787?v=4?s=100" width="100px;" alt="dr41d45"/><br /><sub><b>dr41d45</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=dr41d45" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/T-Joseph-Kim"><img src="https://avatars.githubusercontent.com/u/116681578?v=4?s=100" width="100px;" alt="Taebok Joseph Kim"/><br /><sub><b>Taebok Joseph Kim</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=T-Joseph-Kim" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luxxmr"><img src="https://avatars.githubusercontent.com/u/185298948?v=4?s=100" width="100px;" alt="luxxmr"/><br /><sub><b>luxxmr</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=luxxmr" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->

92
ugit
View file

@ -7,8 +7,9 @@ set -uo pipefail;
SCRIPT_NAME="$0"
SCRIPT_URL="https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit"
TMP_FILE="/tmp/ugit.sh"
VERSION="5.3"
VERSION="5.9"
pointer=""
BOLD_ORG_FG=$(tput bold)$(tput setaf 208)
BOLD=$(tput bold)
RESET=$(tput sgr0)
@ -64,7 +65,7 @@ undo_git_commit() {
# This will not delete the files from your working directory
if [[ "$last_commit" == "$initial_commit" ]]; then
if git update-ref -d HEAD && git rm --cached -rf . > /dev/null 2>&1; then
printf "%s\nInitial commit: $initial_commit successfully undone. Commit state is clean."
printf "%s\n" "Initial commit: $initial_commit successfully undone. Commit state is clean."
else
perror "Error: Failed to revert initial commit"
exit
@ -185,15 +186,21 @@ undo_git_merge() {
}
recover_lost_stash() {
LOST_STASH=$(git fsck --no-progress --unreachable | \
awk '/commit/ {print $3}' | \
xargs git log --color --oneline --merges --no-walk | \
fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}'
LOST_STASH=$(git fsck --no-progress --unreachable |
awk '/commit/ {print $3}' |
xargs git log --color --oneline --merges --no-walk
)
[[ "$LOST_STASH" ]] && read -p "Enter Stash Description: " -r STASH_MSG || exit
if [ -z "$LOST_STASH" ]; then
printf "%s\n" "No unreachable commits found. Exiting..."
exit
fi
if git update-ref refs/stash "$LOST_STASH" --create-reflog -m "$STASH_MSG"; then
STASH=$(echo "$LOST_STASH" | fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}')
read -p "Enter Stash Description: " -r STASH_MSG
if git update-ref refs/stash "$STASH" --create-reflog -m "$STASH_MSG"; then
printf "%s\n" "Stash Successfully Recovered 👍️"
else
perror "Unable to recover stash"
@ -239,12 +246,21 @@ recover_deleted_tag() {
undo_file_delete() {
if [[ "$1" = "uncommited" ]]; then
# user didn't commit the file deletion
DELETED_FILE=$(git ls-files -d | fzf --ansi --height 20% --reverse --header="Choose deleted file to recover" | awk '{print $1}')
if git checkout HEAD "$DELETED_FILE"; then
printf "%s\n" "${BOLD}$DELETED_FILE${RESET} Successfully Recovered 👍️"
readarray -t DELETED_FILES < <(
git ls-files -d |
fzf --ansi --height 20% --reverse --header="Choose deleted files to recover" --multi |
awk '{print $1}'
)
if [ ${#DELETED_FILES[@]} -eq 0 ]; then
exit 0
fi
if git checkout HEAD -- "${DELETED_FILES[@]}"; then
printf "%s\n" "${BOLD}${DELETED_FILES[*]}${RESET}"
printf "%s\n" "Successfully Recovered ${#DELETED_FILES[@]} file(s)"
else
perror "Unable to recover ${BOLD}$DELETED_FILE${RESET}"
perror "Unable to recover ${BOLD}${DELETED_FILES[*]}${RESET}"
fi
elif [[ "$1" = "commited" ]]; then
read -p "Enter complete filename: " -r FILENAME
@ -318,7 +334,7 @@ undo_git_tag() {
perror "Unable to fetch tags from remote.Please check repository access."
exit
fi
tag=$(git tag | fzf --ansi --height 80% \
tag=$(git tag --sort=v:refname | fzf --ansi --height 80% \
--reverse --multi --header="Choose a tag to remove" \
--preview "echo {} | cut -d' ' -f1 | xargs -I{} git show --color --pretty=format:%b {}" \
--bind 'j:down,k:up,ctrl-j:preview-down,ctrl-k:preview-up,ctrl-space:toggle-preview' --preview-window right:60% )
@ -344,7 +360,7 @@ undo_git_tag() {
undo_git_rm(){
# Find all the deleted files from git history
filepath=$(git log --diff-filter=D --summary | grep delete | nl -n ln | fzf --header="Choose the file to restore" --height 50% --ansi --reverse --pointer='👉' --cycle | awk '{print $5}')
filepath=$(git log --diff-filter=D --summary | grep delete | nl -n ln | fzf --header="Choose the file to restore" --height 50% --ansi --reverse "$pointer" --cycle | awk '{print $5}')
# Find the commit hash value of the selected filepath
commit=$(git log -- "$filepath"| awk 'NR==1{print $2}')
@ -403,6 +419,12 @@ check_deps() {
for dep in "${deps[@]}"; do
installed "${dep}" || die "Missing dependency: '${dep}'"
done
# if version of fzf < 0.21, do not use --pointer
fzf_version=$(fzf --version | cut -d "." -f 1,2 | tr -d '.()[:alpha:]')
if test "$fzf_version" -ge 021; then
pointer="--pointer=👉"
fi
}
show_version() {
@ -410,22 +432,17 @@ show_version() {
}
print_help() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-u] [-g]
ugit helps you undo git commands without much effort
Just run 'ugit' and search for what you want to undo
Available options:
-h, --help Print this help and exit
-v, --version Print current ugit version
-u, --update Update ugit
-g, --guide Open ugit undo text guide
EOF
printf "\n%s\n" "Contact 📬️: $(tput bold)varshneybhupesh@gmail.com${RESET} for assistance"
printf "%s\n" "Read the guide: https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git"
printf "\n%s\n" "Please give us ⭐ a if you liked ugit ${BOLD_ORG_FG}https://github.com/Bhupesh-V/ugit${RESET}"
printf "Usage: %s [-h] [-v] [-u] [-g]\n" "ugit"
printf "ugit helps you undo git commands without much effort\n"
printf "Just run 'ugit' and search for what you want to undo\n\n"
printf "Available options:\n"
printf " -h, --help Print this help and exit\n"
printf " -v, --version Print current ugit version\n"
printf " -u, --update Update ugit\n"
printf " -g, --guide Open the ugit undo text guide\n\n"
printf "Contact 📬️: %s for assistance\n" "$(tput bold)varshneybhupesh@gmail.com${RESET}"
printf "Read the guide: %s\n" "https://til.bhupesh.me/git/how-to-undo-anything-in-git"
printf "Please give us a ⭐ if you liked ugit %s\n" "${BOLD_ORG_FG}https://github.com/Bhupesh-V/ugit${RESET}"
}
get_changelog() {
@ -436,6 +453,12 @@ get_changelog() {
}
ugit_update() {
if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then
printf "%s\n\n" "You are running version ${VERSION} of ugit via Docker. Please pull the latest docker image to update."
printf "\t%s\n" "${BOLD_ORG_FG}docker pull bhupeshimself/ugit${RESET}"
return
fi
printf "%s\n" "Checking for updates ..."
curl -s -L "$SCRIPT_URL" > "$TMP_FILE"
NEW_VER=$(grep "^VERSION" "$TMP_FILE" | awk -F'[="]' '{print $3}')
@ -455,7 +478,12 @@ ugit_update() {
}
open_guide() {
GUIDE="https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git"
GUIDE="https://til.bhupesh.me/git/how-to-undo-anything-in-git"
if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then
printf "%s\n" "You can find how ugit does its magic at: ${BOLD_ORG_FG}${GUIDE}${RESET}"
return
fi
case "$OSTYPE" in
darwin*)
@ -513,7 +541,7 @@ main() {
check_deps
init_test
header
option=$(display_menu | nl -n ln | fzf --header="Don't worry we all mess up sometimes" --height 50% --ansi --reverse --pointer='👉' --cycle | awk '{print $1}')
option=$(display_menu | nl -n ln | fzf --header="Don't worry we all mess up sometimes" --height 50% --ansi --reverse "$pointer" --cycle | awk '{print $1}')
ugit_menu
fi
}

2
ugit-flatpak/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.flatpak-builder
build-dir

View file

@ -0,0 +1,45 @@
app-id: org.Bhupesh-V.ugit
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: ugit
finish-args:
- --filesystem=home:rw
- --share=network
modules:
- name: fzf
buildsystem: simple
build-commands:
- tar -xvf fzf-0.33.0-linux_amd64.tar.gz
- install -Dm755 fzf ${FLATPAK_DEST}/bin/fzf
sources:
- type: file
url: https://github.com/junegunn/fzf/releases/download/0.33.0/fzf-0.33.0-linux_amd64.tar.gz
sha256: bcf2f4ba957cce15cea1546f48cdd3bfe9b5dc9a6e80ccc400314bda171466f3
- name: git
buildsystem: simple
build-commands:
- install -Dm755 $(which git) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-cvsserver) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-receive-pack) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-shell) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-upload-archive) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-upload-pack) ${FLATPAK_DEST}/bin/
- name: ugit
buildsystem: simple
build-options:
build-commands:
- chmod +x ugit
- install -Dm755 ugit ${FLATPAK_DEST}/bin/ugit
- install -Dm755 org.Bhupesh-V.ugit.desktop ${FLATPAK_DEST}/share/applications/org.Bhupesh-V.ugit.desktop
sources:
- type: git
url: https://github.com/Bhupesh-V/ugit
tag: v5.3
commit: 14da50780e696e758bf362489496b74901f84cc1
- type: file
path: org.Bhupesh-V.ugit.desktop

View file

@ -0,0 +1,5 @@
[Desktop Entry]
Name=ugit
Exec=ugit
Type=Application
Terminal=true