-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc_git
54 lines (45 loc) · 2.65 KB
/
.bashrc_git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
#
# The bashrc for git module.
#
alias git-count-commits-shortlog='git submodule foreach --recursive git shortlog -s -n -e --all --no-merges'
alias git-ignore-dot-idea-folder='echo "*" >> .idea/.gitignore';
# Print out the history log in oneline with a prefix of '- ', of the current branch by default.
# @see https://git-scm.com/docs/pretty-formats
alias git-log-dash-oneline='git log --format="- %s"';
alias git-tags='git tag -l -n9';
# Push/Pull the local commits of the master and development branches to/from origin.
alias git-push-origin-master-and-development='git push origin master development';
alias git-pull-origin-master-and-development='git pull origin master development';
# Set the remote tracking urls of origin to https(fetch) and git(push).
git-remote-github ()
{
if [ -z "$1" ]; then
( echo -e "\e[01;33mYou should specifying the path of your repository.\e[0m" 1>&2 );
( echo -e "\e[01;33mUsage: git-remote-github user-name/repo-path" 1>&2 );
git remote -v
return;
fi;
local mRepoPath=$1;
git remote -v
set -o xtrace
git remote set-url origin https://github.com/${mRepoPath}.git
git remote set-url origin --push git@github.com:${mRepoPath}.git
set +o xtrace
git remote -v
}
# gitrsm = Git Recursive SubModules.
alias gitrsm-simplified-status='git submodule status --recursive'
alias gitrsm-detailed-status='git submodule foreach --recursive git status'
alias gitrsm-local-status='git submodule foreach --recursive "git status | grep --color=always \"(new commits\|modified content)\" || true && echo"'
alias gitrsm-remote-status='git submodule foreach --recursive "git status | grep --color=always \"ahead.*commits*.\" || true && echo"'
alias gitrsm-status='git submodule foreach --recursive "git status | grep --color=always \"ahead.*commits*.\|(new commits\|modified content)\" || true && echo"'
alias gitrsm-count-commits='git submodule foreach --recursive git shortlog -s -n -e --all --no-merges'
alias gitrsm-config-user-info-local='git submodule foreach --recursive "git config --local --list | grep user || true && echo"'
alias gitrsm-pull='git submodule foreach --recursive git pull origin master'
alias gitrsm-raw-push='git submodule foreach --recursive git push origin master'
cmdGitPushIfNeeded='git status | grep ahead && echo Pushing from ${toplevel}/${name} && git push origin master || true'
alias gitrsm-push-works="git submodule foreach --recursive '${cmdGitPushIfNeeded}'"
alias gitrsm-checkout-master='git submodule foreach --recursive git checkout master'
alias gitrsm-fetch='git submodule foreach --recursive git fetch origin master'
alias gitrsm-merge-origin-master='git submodule foreach --recursive git merge origin/master'