66 Commits

Author SHA1 Message Date
Ivan Malopinsky 7d0d33d32b Merge pull request #93 from imsky/main
Add support for main branch as root
2020-10-27 19:24:51 -04:00
Ivan Malopinsky b2fd270558 1.13.0 2020-10-27 19:23:55 -04:00
Ivan Malopinsky 3d7177e84c if only main branch exists, use that as root 2020-10-27 19:22:46 -04:00
Ivan Malopinsky 8bbe2a7d49 Merge pull request #92 from hrishabh23/ppwd
Change dir to repo root before making changes
2019-10-12 14:50:53 -04:00
Hrishabh 136a777d73 Change dir to repo root before making changes 2019-10-12 01:34:54 +05:30
Ivan Malopinsky 9dd178ded8 1.12.1 2019-06-23 20:07:35 -04:00
Ivan Malopinsky 6ad55433df use correct commit from log for root recovery 2019-05-27 15:54:48 -04:00
Ivan Malopinsky cf050df1f6 fix recovery logic, recover root before getting current commit 2019-05-27 15:39:44 -04:00
Ivan Malopinsky 074154e726 add root HEAD recovery function 2019-05-27 15:30:07 -04:00
Ivan Malopinsky 900e9120b5 update LICENSE years 2019-01-21 18:09:47 -05:00
Ivan Malopinsky 8b0bc89eb8 minor tweaks to get around groff treating leading . as a special character 2019-01-21 18:08:56 -05:00
Ivan Malopinsky 3825d93ff6 1.12.0 2019-01-21 17:43:51 -05:00
Ivan Malopinsky 08f63dbdd4 install man page 2019-01-21 17:43:16 -05:00
Ivan Malopinsky 9a768e9b48 add more spacing to man page sections 2019-01-21 17:25:51 -05:00
Ivan Malopinsky 83f2c7c80b add git-fresh man page
fix #82
2019-01-21 17:23:25 -05:00
Ivan Malopinsky 57cdc7c0fa add --help flag 2019-01-21 16:58:52 -05:00
Ivan Malopinsky 48429ea4df add flag to clear stashed changes
fix #88
2019-01-21 16:47:42 -05:00
Ivan Malopinsky 57f08a9758 print an error message along with the error line
fix #89
2019-01-21 16:41:31 -05:00
Ivan Malopinsky 23a3a64d90 Merge pull request #86 from hultberg/patch-1
Added archlinux package
2018-02-19 13:18:44 -05:00
Edvin Hultberg 5953344240 Added archlinux package 2018-02-19 10:19:40 +01:00
Ivan Malopinsky c6fcd81155 Merge pull request #84 from koppor/patch-1
Add installation hints for Windows
2017-12-08 09:07:07 -05:00
Oliver Kopp 5b99160266 Add installation hints for Windows 2017-12-08 09:11:52 +01:00
Ivan Malopinsky 38e71f6f9d update git-fresh docs 2017-11-14 23:06:46 -05:00
Ivan Malopinsky fa9b2a38b1 1.11.0 2017-11-14 23:04:37 -05:00
Ivan Malopinsky d3f7a39b96 do not rebase local current branch against remote branch. ff-merge instead of rebasing local root 2017-11-14 23:03:43 -05:00
Ivan Malopinsky bc874fa5bd run git prune if git gc fails
resolve #83
2017-11-14 22:51:48 -05:00
Ivan Malopinsky f0c9f902a4 1.10.1 2017-07-19 20:07:55 -04:00
Ivan Malopinsky b9e145abdf Create LICENSE 2017-07-18 21:12:02 -04:00
Ivan Malopinsky a129ad766a git remote prune before remote update, resolve #79 #80 2017-07-18 21:09:27 -04:00
Ivan Malopinsky 8f4a8a326e support a global .freshignore, fix #76 2017-07-18 20:50:55 -04:00
Ivan Malopinsky 8974b650ac recover HEAD ref, fix #77 2017-04-25 22:49:30 -04:00
Ivan Malopinsky e5ac597258 .freshignore support for local and remote branch cleanup 2016-09-30 22:13:52 -04:00
Ivan Malopinsky 9999e54375 start on branch ignore support 2016-09-25 22:55:09 -04:00
Ivan Malopinsky 30657dcd75 clean tracking information for missing upstreams
fix #63
2016-09-24 22:55:09 -04:00
Ivan Malopinsky 0b191ec2f9 1.8.0 2016-08-25 20:29:41 -04:00
Ivan Malopinsky 562a4b94ca do not change branch if already on root, add tests 2016-08-25 20:29:19 -04:00
Ivan Malopinsky 799199dcc2 add version command 2016-07-04 00:00:00 -04:00
Ivan Malopinsky 33df53a989 bump version to 1.7.0 2016-05-14 00:00:00 -04:00
Ivan Malopinsky ad4a370334 update docs with -R and -W 2016-05-13 00:00:00 -04:00
Ivan Malopinsky 58851c4c15 add -W and -R to split -F 2016-05-12 00:00:00 -04:00
Ivan Malopinsky d33bde493a bump to 1.6.2 2016-03-30 12:23:19 -04:00
Ivan Malopinsky 9a061ce30b reset/rebase against remote branches 2016-03-29 11:05:34 -04:00
Ivan Malopinsky 236f95ea18 merge/rebase against local root
fix #68
2016-03-28 17:34:47 -04:00
Ivan Malopinsky 2da11516b4 1.6.1 2016-03-22 22:20:19 -04:00
Ivan Malopinsky e735f44727 integrated testing mode 2016-03-22 22:20:14 -04:00
Ivan Malopinsky 8f40e82492 1.6.0 2016-03-22 22:02:03 -04:00
Ivan Malopinsky da4e21fe5c add remote testing 2016-03-22 22:01:24 -04:00
Ivan Malopinsky 01a44ddc7c replace spaces with NULs for xargs -0 2016-03-09 22:45:08 -05:00
Ivan Malopinsky 0702c3a67b only run remote commands if remote is present, rework rebase/reset 2016-03-09 22:38:49 -05:00
Ivan Malopinsky bcde137050 bump to 1.5.0 2016-03-09 19:43:58 -05:00
Ivan Malopinsky da31f19926 Merge pull request #66 from imsky/quotes-xargs
fix xargs failure for branches with quotes in names
2016-03-08 23:40:56 -05:00
Ivan Malopinsky 2b1fb56c4a fix xargs failure for branches with quotes in names
fix #65
2016-03-08 23:40:44 -05:00
Ivan Malopinsky 4f142bf0dd update readme to include tag option 2016-02-28 00:06:48 -05:00
Ivan Malopinsky 5c76da3ebd Merge pull request #64 from imsky/stale-tags
remove local tags that do not exist on remote, fix #62
2016-02-27 18:35:53 -05:00
Ivan Malopinsky 0d632b15e1 remove local tags that do not exist on remote, fix #62 2016-02-27 18:35:29 -05:00
Ivan Malopinsky f6898b7056 1.4.0 2016-01-21 23:16:00 -05:00
Ivan Malopinsky ae2fa19df6 add [git-fresh] to logs 2016-01-20 00:00:00 -05:00
Ivan Malopinsky 2798299f11 add comments 2016-01-19 00:00:00 -05:00
Ivan Malopinsky f3fb0fc3f9 check that remote branch exists before rebasing against it 2016-01-17 00:00:00 -05:00
Ivan Malopinsky c7d9abc59e fix HEAD ref check 2016-01-16 00:00:00 -05:00
Ivan Malopinsky 80593359ca fix git directory check 2016-01-15 00:00:00 -05:00
Ivan Malopinsky 337c9679bc homebrew now supported 2015-12-08 20:13:26 -05:00
Ivan Malopinsky f18a2dc6ba add safety checks before running git-fresh 2015-12-03 20:28:04 -05:00
Ivan Malopinsky 97c7dfb4b5 bump to 1.2.3 2015-12-03 12:45:31 -05:00
Ivan Malopinsky 46a74c1b08 Merge pull request #58 from bfontaine/patch-1
install: create the parent directory if necessary
2015-12-03 12:34:50 -05:00
Baptiste Fontaine b9336549c1 install: create the parent directory if necessary
This ensures the parent directory always exists.
2015-12-03 18:28:25 +01:00
7 changed files with 452 additions and 70 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-2020 Ivan Malopinsky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+38 -16
View File
@@ -1,39 +1,61 @@
# git-fresh :lemon:
# git-fresh :lemon:
Keep your repo fresh with one command.
## Usage
```
Usage: git fresh [-fmrF] [-sl] [remote] [root]
By default, git-fresh will:
- rebase against remote current branch
- stash changes
- prune remote branches
SYNOPSIS
git-fresh [-fmrtRWS] [-sl] [remote] [root]
-f: Delete stale local and remote branches
-m: Merge remote root into current branch
-r: Rebase current branch against remote root
-F: Reset local root to remote root, wipe workspace
DESCRIPTION
git-fresh helps keep your Git repo fresh.
-s: Apply stashed changes after run
-l: Only delete local stale branches
By default, git-fresh will:
- update local root (master) to match remote root
- stash changes
- prune remote branches
remote: remote name, origin by default
root: root branch, master by default
git-fresh will ignore any branches listed in a .freshignore file.
.freshignore should contain branch names you would like to ignore
on separate lines. The file can exist in the current Git repo
or in the home directory, i.e. ~/.freshignore.
remote is origin by default. root is master by default.
OPTIONS
-f Delete stale local and remote branches
-m Merge remote root into current branch
-r Rebase current branch against remote root
-t Remove local tags that do not exist on remote
-R Reset local root to remote root
-W Wipe workspace clean
-S Clear all stash entries
-s Apply stashed changes after run
-l Only delete local stale branches
-v Print git-fresh version and exit
```
## Installation
### Manual
### Manual on Linux or macOS
1. Clone or download
2. `cd git-fresh`
3. `sudo ./install`
3. `sudo ./install.sh`
### Manual on Windows
Copy the file [git-fresh](https://raw.githubusercontent.com/imsky/git-fresh/master/git-fresh) to `usr\bin` in your git installation directory.
This usually is `C:\Program Files\Git\usr\bin`.
### Package
* [Homebrew](http://brew.sh/): `brew install git-fresh`
* [bpkg](http://www.bpkg.io/): `bpkg install imsky/git-fresh`
* [AUR](https://aur.archlinux.org/): [git-fresh](https://aur.archlinux.org/packages/git-fresh/)
## License
+302 -48
View File
@@ -1,35 +1,79 @@
#!/usr/bin/env bash
# generate man page with: txt2man.sh -t git-fresh <(./git-fresh -?) > git-fresh.1
# git-fresh
# https://github.com/imsky/git-fresh
# By Ivan Malopinsky - http://imsky.co
# MIT License
usage () {
cat << EOD
Usage: git fresh [-fmrF] [-sl] [remote] [root]
By default, git-fresh will:
- rebase against remote current branch
- stash changes
- prune remote branches
cat << EOT
NAME
git-fresh
-f: Delete stale local and remote branches
-m: Merge remote root into current branch
-r: Rebase current branch against remote root
-F: Reset local root to remote root, wipe workspace
SYNOPSIS
git-fresh [-fmrtRWS] [-sl] [remote] [root]
-s: Apply stashed changes after run
-l: Only delete local stale branches
DESCRIPTION
git-fresh helps keep your Git repo fresh.
remote: remote name, origin by default
root: root branch, master by default
EOD
By default, git-fresh will:
- update local root (master) to match remote root
- stash changes
- prune remote branches
exit 0;
git-fresh will ignore any branches listed in a .freshignore file.
freshignore should contain branch names you would like to ignore
on separate lines. The file can exist in the current Git repo
or in the home directory, i.e. ~/.freshignore.
remote is origin by default. root is master by default.
OPTIONS
-f Delete stale local and remote branches
-m Merge remote root into current branch
-r Rebase current branch against remote root
-t Remove local tags that do not exist on remote
-R Reset local root to remote root
-W Wipe workspace clean
-S Clear all stash entries
-s Apply stashed changes after run
-l Only delete local stale branches
-v Print git-fresh version and exit
BUGS
Issues are tracked on GitHub: https://github.com/imsky/git-fresh
AUTHOR
Ivan Malopinsky - http://imsky.co
EOT
exit 0
}
say () {
echo "[git-fresh] $@" 1>&2
}
die () {
say $@
exit 1
}
error () {
echo -n "[git-fresh] error on line $1"
ERR=${ERR:-unknown}
die "Error on line $1: $ERR"
}
trap 'error $LINENO' ERR
while getopts ":fmrslF" opt; do
if [[ "$1" = '--help' ]]; then
usage
fi
while getopts ":fmrtslRWSTv" opt; do
case $opt in
f)
FORCE_DELETE_STALE=true
@@ -40,14 +84,29 @@ while getopts ":fmrslF" opt; do
r)
REBASE=true
;;
t)
TAGS=true
;;
s)
APPLY_STASH=true
;;
l)
DELETE_ONLY_LOCAL=true
;;
F)
FORCE_LOCAL_RESET=true
R)
RESET_ROOT=true
;;
W)
WIPE_WORKSPACE=true
;;
S)
CLEAR_STASH=true
;;
T)
TEST=true
;;
v)
VERSION=1.12.1
;;
*)
usage
@@ -58,30 +117,152 @@ done
shift $((OPTIND-1))
CURRENT=$(git rev-parse --abbrev-ref HEAD)
REMOTE=${1:-origin}
ROOT=${2:-master}
# Are we in version mode?
git remote update
git remote prune $REMOTE
if [[ ! -z $VERSION ]]; then
echo git-fresh $VERSION
exit 0
fi
# Are we in testing mode?
if [[ $TEST = true ]]; then
PATH=$(pwd):$PATH
TEST_DIR=/tmp/git-fresh-test
fail_test () {
echo 'Tests failed!'
rm -rf $TEST_DIR
exit 1
}
rm -rf $TEST_DIR; mkdir -p $TEST_DIR; cd $TEST_DIR
git init; touch test; git add test; git commit -am 'test'
git checkout -b test; rm test; git commit -am 'delete test'
git checkout master; git merge test; git checkout test
git-fresh -fr; git rev-parse --verify test && fail_test || true
git checkout -b test; git checkout master; git-fresh; git checkout -
git rev-parse --abbrev-ref HEAD | grep -q test || fail_test
rm -rf $TEST_DIR
echo 'Tests passed!'
exit 0
fi
# Are we inside a git repository?
INSIDE_GIT_REPO=$(git rev-parse --is-inside-work-tree 2> /dev/null)
if [[ -z "$INSIDE_GIT_REPO" ]]; then
die "Not a git repository"
fi
# Are we in a non-empty git repository?
ERR="could not get top-level-directory"
TOP_LEVEL_DIRECTORY=$(git rev-parse --show-toplevel)
REMOTE=${1:-origin}
ROOT_GUESS=master
if [[ -n $(git show-ref refs/heads/main) && -z $(git show-ref refs/heads/master) ]]; then
ROOT_GUESS=main
fi
ROOT=${2:-$ROOT_GUESS}
# Recover the root HEAD if it is missing or corrupt (e.g. master head reads "master")
recover_root () {
ROOT_HEAD_FILE="$TOP_LEVEL_DIRECTORY/.git/refs/heads/$ROOT"
if [[ -e "$ROOT_HEAD_FILE" ]]; then
if [[ $(cat "$ROOT_HEAD_FILE") = $(echo $ROOT) ]]; then
CORRUPT_ROOT_HEAD=true
fi
else
MISSING_ROOT_HEAD=true
fi
if [[ "$CORRUPT_ROOT_HEAD" = "true" || "$MISSING_ROOT_HEAD" = "true" ]]; then
ERR="failed to recover $ROOT HEAD"
RECOVERED_ROOT_HEAD=$(cat "$TOP_LEVEL_DIRECTORY/.git/logs/refs/heads/$ROOT" | tail -n1 | cut -d' ' -f2)
echo "$RECOVERED_ROOT_HEAD" > "$ROOT_HEAD_FILE"
say "Recovered $ROOT HEAD, set to $RECOVERED_ROOT_HEAD"
CORRUPT_ROOT_HEAD=false
MISSING_ROOT_HEAD=false
fi
}
recover_root
LAST_WORKING_DIRECTORY="$(pwd)"
cd "$TOP_LEVEL_DIRECTORY"
ERR="could not get current commit"
CURRENT=$(git rev-parse --abbrev-ref HEAD)
ERR=""
if [[ $(git remote -v | wc -l) -gt "0" ]]; then
REMOTES=true
fi
# Is this branch in .freshignore?
FRESH_IGNORE="$TOP_LEVEL_DIRECTORY/.freshignore"
if [[ ! -f $FRESH_IGNORE ]]; then
FRESH_IGNORE="~/.freshignore"
fi
if [[ -f $FRESH_IGNORE ]]; then
if [[ ! -z $(grep -Fx "$CURRENT" "$FRESH_IGNORE") ]]; then
die "Branch $CURRENT is ignored"
fi
fi
STASH_STAMP=git-fresh-$(date +%s)
# Stash changed files
if ! git diff-files --quiet; then
ERR="could not stash changes"
git stash save $STASH_STAMP
fi
git rebase $REMOTE $CURRENT
git checkout $ROOT > /dev/null 2>&1
if [[ "$FORCE_LOCAL_RESET" = true ]]; then
git clean -dfx
git reset --hard $REMOTE/$ROOT
else
git rebase -q $REMOTE/$ROOT
if [[ $REMOTES = true ]]; then
# Update remotes and prune stale remotes
ERR="could not update and prune remotes"
git remote prune $REMOTE
git remote update $REMOTE
git remote prune $REMOTE
fi
# If we are not already on root branch, switch to root branch (master)
if [[ "$ROOT" != "$CURRENT" ]]; then
ERR="could not check out $ROOT branch"
git checkout $ROOT > /dev/null 2>&1
fi
# Wipe workspace?
if [[ $WIPE_WORKSPACE = true ]]; then
ERR="could not wipe workspace"
git clean -dfx
fi
if [[ $REMOTES = true ]]; then
# Reset root?
if [[ $RESET_ROOT = true ]]; then
ERR="could not reset root"
git reset --hard $REMOTE/$ROOT
fi
ERR="could not perform fast forward merge"
git pull --quiet --ff-only $REMOTE $ROOT || say "Fast forward merge failed on $ROOT. You can reset local $ROOT by running git fresh -R."
fi
# Compute stale branches
ERR="could not determine stale branches"
SMART_STALE=$(git branch -a --merged | tr -d "\* " | grep -Ev ">|$ROOT" | cat)
LOCAL_STALE=$(grep -Ev "^remotes/" <<< "$SMART_STALE" | cat)
@@ -93,53 +274,126 @@ REMOTE_STALE=${REMOTE_STALE//remotes\/$REMOTE\/}
if [[ ! -z "${SMART_STALE// }" ]]; then
if [[ ! -z "${LOCAL_STALE// }" ]]; then
STALE_BRANCHES=true
if [[ -f "$FRESH_IGNORE" ]]; then
LOCAL_STALE=$(echo -n $LOCAL_STALE | tr " " "\n" | grep -Fxvf "$FRESH_IGNORE" | tr "\n" " ")
if [[ -z $LOCAL_STALE ]]; then
STALE_BRANCHES=false
fi
fi
if [[ "$FORCE_DELETE_STALE" = true ]]; then
echo -n $LOCAL_STALE | xargs git branch -d 2> /dev/null
ERR="could not delete stale local branches: $LOCAL_STALE"
echo -n $LOCAL_STALE | tr " " "\0" | xargs -0 git branch -d 2> /dev/null
else
echo "Local stale branches found:" $(echo -n $LOCAL_STALE | tr "\n" " ")
if [[ $STALE_BRANCHES = true ]]; then
say "Local stale branches found:" $(echo -n $LOCAL_STALE | tr "\n" " ")
fi
fi
fi
if [[ ! -z "${REMOTE_STALE// }" ]]; then
STALE_BRANCHES=true
if [[ -f "$FRESH_IGNORE" ]]; then
REMOTE_STALE=$(echo -n $REMOTE_STALE | tr " " "\n" | grep -Fxvf "$FRESH_IGNORE" | tr "\n" " ")
if [[ -z $REMOTE_STALE ]]; then
STALE_BRANCHES=false
fi
fi
if [[ "$FORCE_DELETE_STALE" = true ]]; then
if [[ "$DELETE_ONLY_LOCAL" != true ]]; then
echo -n $REMOTE_STALE | xargs git push $REMOTE --delete
ERR="could not delete stale remote branches: $REMOTE_STALE"
echo -n $REMOTE_STALE | tr " " "\0" | xargs -0 git push $REMOTE --delete
fi
else
echo "Remote stale branches found:" $(echo -n $REMOTE_STALE | tr "\n" " ")
if [[ $STALE_BRANCHES = true ]]; then
say "Remote stale branches found:" $(echo -n $REMOTE_STALE | tr "\n" " ")
fi
fi
fi
if [[ "$FORCE_DELETE_STALE" != true && "$STALE_BRANCHES" = true ]]; then
echo "Delete stale branches with: git fresh -f"
say "Delete stale branches with: git fresh -f"
fi
fi
# Remove tracking information for missing upstreams
if [[ ! -z $(git branch -vv | grep -F "[$REMOTE/$CURRENT: gone]") ]]; then
git branch --unset-upstream $CURRENT
fi
# Rebase or merge remote root against local branch
if [[ ! -z $(git rev-parse --verify --quiet "$CURRENT") ]]; then
git checkout $CURRENT 2> /dev/null
if [[ "$ROOT" != "$CURRENT" ]]; then
ERR="could not check out $CURRENT branch"
git checkout $CURRENT
recover_root
fi
if [ "$REBASE" = true ] && [ "$MERGE" = true ]; then
echo "Rebase and merge enabled, skipping both"
say "Rebase and merge enabled, skipping both"
else
if [[ "$REBASE" = true ]]; then
git rebase $REMOTE/$ROOT
fi
if [[ "$REMOTES" = true ]]; then
if [[ "$REBASE" = true ]]; then
ERR="could not rebase against $ROOT branch"
git rebase $ROOT
fi
if [[ "$MERGE" = true ]]; then
git merge --no-edit $REMOTE/$ROOT
if [[ "$MERGE" = true ]]; then
ERR="could not merge $ROOT branch"
git merge --no-edit $ROOT
fi
fi
fi
else
echo "$CURRENT branch was stale, staying on $ROOT"
fi
# Remove local tags that are missing on the remote
if [[ "$TAGS" = true ]]; then
ERR="could not get remote tags"
REMOTE_TAGS=$(git ls-remote --tags $REMOTE | cut -f 2)
LOCAL_TAGS=$(git show-ref --tags | cut -d' ' -f 2)
for tag in $LOCAL_TAGS; do
if [[ -z $(grep $tag <<< "$REMOTE_TAGS" | cat) ]]; then
MISSING_TAG="${tag//refs\/tags\/}"
git tag -d $MISSING_TAG
fi
done
fi
# Restore stashed changes
if [[ ! -z $(git stash list | grep $STASH_STAMP | cat) ]]; then
if [[ "$APPLY_STASH" = true ]]; then
ERR="could not apply stashed changes"
git stash pop
else
echo "Stashed changes present, apply with: git stash pop"
say "Stashed changes present, apply with: git stash pop"
fi
fi
git gc --auto --prune=now
# Clear stashed changes
if [[ "$CLEAR_STASH" = true ]]; then
ERR="could not clear stashed changes"
git stash clear
fi
if ! git gc --auto --force; then
ERR="git prune failed"
git prune
rm -rf "$TOP_LEVEL_DIRECTORY/.git/gc.log"
fi
if [[ -d "$LAST_WORKING_DIRECTORY" ]]; then
cd "$LAST_WORKING_DIRECTORY"
else
say "Previous working directory does not exist on the branch $ROOT"
fi
recover_root
ERR=""
+73
View File
@@ -0,0 +1,73 @@
." Text automatically generated by txt2man
.TH git-fresh "January 21, 2019" "" ""
.SH NAME
\fBgit-fresh
\fB
.SH SYNOPSIS
.nf
.fam C
\fBgit-fresh\fP [\fB-fmrtRWS\fP] [\fB-sl\fP] [\fIremote\fP] [\fIroot\fP]
.fam T
.fi
.SH DESCRIPTION
\fBgit-fresh\fP helps keep your Git repo fresh.
.PP
By default, \fBgit-fresh\fP will:
.IP \(hy 3
update local \fIroot\fP (master) to match \fIremote\fP \fIroot\fP
.IP \(hy 3
stash changes
.IP \(hy 3
prune \fIremote\fP branches
.PP
\fBgit-fresh\fP will ignore any branches listed in a .freshignore file.
\ .freshignore should contain branch names you would like to ignore
on separate lines. The file can exist in the current Git repo
or in the home directory, i.e. ~/.freshignore.
.PP
\fIremote\fP is origin by default. \fIroot\fP is master by default.
.SH OPTIONS
.TP
.B
\fB-f\fP
Delete stale local and \fIremote\fP branches
.TP
.B
\fB-m\fP
Merge \fIremote\fP \fIroot\fP into current branch
.TP
.B
\fB-r\fP
Rebase current branch against \fIremote\fP \fIroot\fP
.TP
.B
\fB-t\fP
Remove local tags that do not exist on \fIremote\fP
.TP
.B
\fB-R\fP
Reset local \fIroot\fP to \fIremote\fP \fIroot\fP
.TP
.B
\fB-W\fP
Wipe workspace clean
.TP
.B
\fB-S\fP
Clear all stash entries
.TP
.B
\fB-s\fP
Apply stashed changes after run
.TP
.B
\fB-l\fP
Only delete local stale branches
.TP
.B
\fB-v\fP
Print \fBgit-fresh\fP version and exit
.SH BUGS
Issues are tracked on GitHub: https://github.com/imsky/\fBgit-fresh\fP
.SH AUTHOR
Ivan Malopinsky - http://imsky.co
-4
View File
@@ -1,4 +0,0 @@
#!/usr/bin/env bash
INSTALL_DIR=${1:-/usr/local/bin}
cp git-fresh $INSTALL_DIR && ([ -e $INSTALL_DIR/git-fresh ] && echo git-fresh installed in $INSTALL_DIR)
Executable
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
INSTALL_DIR=${1:-/usr/local/bin}
mkdir -p $INSTALL_DIR
cp git-fresh $INSTALL_DIR && ([ -e $INSTALL_DIR/git-fresh ] && echo git-fresh installed in $INSTALL_DIR)
if [[ -e /usr/local/man ]]; then
MAN_DIR=/usr/local/man
elif [[ -e /usr/local/share/man ]]; then
MAN_DIR=/usr/local/share/man
fi
if [[ ! -z "$MAN_DIR" ]]; then
mkdir -p "$MAN_DIR/man1"
cp git-fresh.1 "$MAN_DIR/man1/" 2> /dev/null || echo Failed to install git-fresh man page
fi
+2 -2
View File
@@ -1,8 +1,8 @@
{
"name": "git-fresh",
"version": "1.2.2",
"version": "1.13.0",
"description": "Utility to keep Git repositories fresh",
"global": true,
"repo": "imsky/git-fresh",
"install": "sudo ./install"
"install": "sudo ./install.sh"
}