Bash/Git: Refactor Git aliases, remove aliases exists in git-extras.
This commit is contained in:
parent
ab3cb53a00
commit
9fbc0e4bb3
@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
* *oo* → open .
|
* *oo* → open .
|
||||||
|
|
||||||
* *marked* → open -a marked
|
|
||||||
|
|
||||||
* *e* → subl
|
* *e* → subl
|
||||||
|
|
||||||
|
* *gh* → github
|
||||||
|
|
||||||
* *+x* → chmod +x
|
* *+x* → chmod +x
|
||||||
|
|
||||||
* *md <dir>* → Make directory and `cd` to it.
|
* *md <dir>* → Make directory and `cd` to it.
|
||||||
|
20
docs/Git.md
20
docs/Git.md
@ -32,27 +32,15 @@ Simple one-line-per-commit log.
|
|||||||
|
|
||||||
Log with list of changed files for each commit.
|
Log with list of changed files for each commit.
|
||||||
|
|
||||||
### git ignore <file mask>
|
### git-append
|
||||||
|
|
||||||
Add new item to `.gitignore`.
|
|
||||||
|
|
||||||
### git this
|
|
||||||
|
|
||||||
Initialize Git repo in current folder and commit all files.
|
|
||||||
|
|
||||||
### git append
|
|
||||||
|
|
||||||
Add all staged files to previous commit.
|
Add all staged files to previous commit.
|
||||||
|
|
||||||
### git undo
|
### git-conflicts
|
||||||
|
|
||||||
Undo last commit withould loosing any changes.
|
|
||||||
|
|
||||||
### git conflicts
|
|
||||||
|
|
||||||
List of files with unresolved conflicts.
|
List of files with unresolved conflicts.
|
||||||
|
|
||||||
### gr
|
### git-root (or gr)
|
||||||
|
|
||||||
Jump to root folder of Git repo.
|
Jump to root folder of Git repo.
|
||||||
|
|
||||||
@ -70,7 +58,7 @@ Add remote upstream.
|
|||||||
|
|
||||||
### git-upstream [branch]
|
### git-upstream [branch]
|
||||||
|
|
||||||
Sync branch with upstream.
|
Sync branch (`master` by default) with upstream.
|
||||||
|
|
||||||
|
|
||||||
## [git-friendly](https://github.com/jamiew/git-friendly)
|
## [git-friendly](https://github.com/jamiew/git-friendly)
|
||||||
|
@ -15,7 +15,7 @@ alias pjm="cd ~/Dropbox/Projects/!"
|
|||||||
alias o="open"
|
alias o="open"
|
||||||
alias oo="open ."
|
alias oo="open ."
|
||||||
alias e="subl"
|
alias e="subl"
|
||||||
alias marked="open -a marked"
|
alias gh="github"
|
||||||
alias +x="chmod +x"
|
alias +x="chmod +x"
|
||||||
|
|
||||||
# Detect which `ls` flavor is in use
|
# Detect which `ls` flavor is in use
|
||||||
@ -82,9 +82,6 @@ password() { openssl rand -base64 ${1:-8} | c; }
|
|||||||
# Show $PATH in a readable way
|
# Show $PATH in a readable way
|
||||||
alias path='echo -e ${PATH//:/\\n}'
|
alias path='echo -e ${PATH//:/\\n}'
|
||||||
|
|
||||||
# Git root
|
|
||||||
alias gr='git rev-parse 2>/dev/null && cd "./$(git rev-parse --show-cdup)"'
|
|
||||||
|
|
||||||
# NPM
|
# NPM
|
||||||
alias npm-patch='npm version patch -m "%s"'
|
alias npm-patch='npm version patch -m "%s"'
|
||||||
alias npm-release='npm version minor -m "%s"'
|
alias npm-release='npm version minor -m "%s"'
|
||||||
|
@ -141,45 +141,6 @@ function yay() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Setup syncronization of current Git repo with GitHub repo of the same name
|
|
||||||
# USAGE: git-github [repo]
|
|
||||||
function git-github() {
|
|
||||||
user="sapegin"
|
|
||||||
repo=${1-`basename "$(pwd)"`}
|
|
||||||
git remote add origin "git@github.com:$user/$repo.git"
|
|
||||||
git push -u origin master
|
|
||||||
}
|
|
||||||
|
|
||||||
# Setup syncronization of current Git repo with Bitbucket repo of the same name
|
|
||||||
# USAGE: git-bitbucket [repo]
|
|
||||||
function git-bitbucket() {
|
|
||||||
user="sapegin"
|
|
||||||
repo=${1-`basename "$(pwd)"`}
|
|
||||||
git remote add origin "git@bitbucket.org:$user/$repo.git"
|
|
||||||
git push -u origin master
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add remote upstream
|
|
||||||
# USAGE: git-fork <original-author>
|
|
||||||
function git-fork() {
|
|
||||||
user=$1
|
|
||||||
if [[ "$user" == "" ]]; then
|
|
||||||
echo "Usage: git-fork <original-author>"
|
|
||||||
else
|
|
||||||
repo=`basename "$(pwd)"`
|
|
||||||
git remote add upstream "git@github.com:$user/$repo.git"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sync branch with upstream
|
|
||||||
# USAGE: git-upstream [branch]
|
|
||||||
function git-upstream() {
|
|
||||||
branch=${1-master}
|
|
||||||
git fetch upstream
|
|
||||||
git checkout $branch
|
|
||||||
git merge upstream/$branch
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find files with Windows line endings (and convert then to Unix in force mode)
|
# Find files with Windows line endings (and convert then to Unix in force mode)
|
||||||
# USAGE: crlf [--force]
|
# USAGE: crlf [--force]
|
||||||
function crlf() {
|
function crlf() {
|
||||||
|
56
includes/bash_git.bash
Normal file
56
includes/bash_git.bash
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# Git related Bash aliases
|
||||||
|
|
||||||
|
github_user="sapegin"
|
||||||
|
bitbucket_user="sapegin"
|
||||||
|
|
||||||
|
|
||||||
|
# `cd` to repo root
|
||||||
|
alias git-root='git rev-parse 2>/dev/null && cd "./$(git rev-parse --show-cdup)"'
|
||||||
|
alias gr="git-root"
|
||||||
|
|
||||||
|
# Setup syncronization of current Git repo with GitHub repo of the same name
|
||||||
|
# USAGE: git-github [repo]
|
||||||
|
function git-github() {
|
||||||
|
local repo=${1-`basename "$(pwd)"`}
|
||||||
|
git remote add origin "git@github.com:$github_user/$repo.git"
|
||||||
|
git push -u origin master
|
||||||
|
}
|
||||||
|
|
||||||
|
# Setup syncronization of current Git repo with Bitbucket repo of the same name
|
||||||
|
# USAGE: git-bitbucket [repo]
|
||||||
|
function git-bitbucket() {
|
||||||
|
local repo=${1-`basename "$(pwd)"`}
|
||||||
|
git remote add origin "git@bitbucket.org:$bitbucket_user/$repo.git"
|
||||||
|
git push -u origin master
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add remote upstream
|
||||||
|
# USAGE: git-fork <original-author>
|
||||||
|
function git-fork() {
|
||||||
|
local user=$1
|
||||||
|
if [[ "$user" == "" ]]; then
|
||||||
|
echo "Usage: git-fork <original-author>"
|
||||||
|
else
|
||||||
|
local repo=`basename "$(pwd)"`
|
||||||
|
git remote add upstream "git@github.com:$user/$repo.git"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sync branch with upstream
|
||||||
|
# USAGE: git-upstream [branch]
|
||||||
|
function git-upstream() {
|
||||||
|
local branch=${1-master}
|
||||||
|
git fetch upstream
|
||||||
|
git checkout $branch
|
||||||
|
git merge upstream/$branch
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add all staged files to previous commit
|
||||||
|
function git-append() {
|
||||||
|
git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
|
||||||
|
}
|
||||||
|
|
||||||
|
# List of files with unresolved conflicts
|
||||||
|
function git-conflicts() {
|
||||||
|
git ls-files -u | awk '{print $4}' | sort -u
|
||||||
|
}
|
@ -61,8 +61,8 @@ INVERT="$(tput sgr 1 0)"
|
|||||||
NOCOLOR="$(tput sgr0)"
|
NOCOLOR="$(tput sgr0)"
|
||||||
|
|
||||||
# Load prompt and aliases
|
# Load prompt and aliases
|
||||||
for file in ~/dotfiles/includes/{bash_prompt,bash_aliases,bash_functions}; do
|
for file in ~/dotfiles/includes/bash_{prompt,aliases,functions,git}.bash; do
|
||||||
[ -r "$file.bash" ] && source "$file.bash"
|
[ -r "$file" ] && source "$file"
|
||||||
done
|
done
|
||||||
unset file
|
unset file
|
||||||
|
|
||||||
|
@ -27,11 +27,6 @@
|
|||||||
s = status -sb
|
s = status -sb
|
||||||
l = log --graph --pretty=format:'%C(magenta)%h%C(blue)%d%Creset %s %C(blue bold)- %an, %ar%Creset'
|
l = log --graph --pretty=format:'%C(magenta)%h%C(blue)%d%Creset %s %C(blue bold)- %an, %ar%Creset'
|
||||||
ll = log --stat --abbrev-commit
|
ll = log --stat --abbrev-commit
|
||||||
ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $2 >> .gitignore
|
|
||||||
this = !git init && git add . && git commit -m \"Initial commit.\"
|
|
||||||
append = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
|
|
||||||
undo = reset --mixed HEAD^
|
|
||||||
conflicts = !git ls-files -u | awk '{print $4}' | sort -u
|
|
||||||
[push]
|
[push]
|
||||||
default = current
|
default = current
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user