Skip to content

Commit 64a0408

Browse files
committed
Fixing commit
1 parent cd0a674 commit 64a0408

File tree

2 files changed

+344
-2
lines changed

2 files changed

+344
-2
lines changed

git-new-workdir

-1
This file was deleted.

git-new-workdir

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
usage () {
4+
echo "usage:" $@
5+
exit 127
6+
}
7+
8+
die () {
9+
echo $@
10+
exit 128
11+
}
12+
13+
if test $# -lt 2 || test $# -gt 3
14+
then
15+
usage "$0 <repository> <new_workdir> [<branch>]"
16+
fi
17+
18+
orig_git=$1
19+
new_workdir=$2
20+
branch=$3
21+
22+
# want to make sure that what is pointed to has a .git directory ...
23+
git_dir=$(cd "$orig_git" 2>/dev/null &&
24+
git rev-parse --git-dir 2>/dev/null) ||
25+
die "Not a git repository: \"$orig_git\""
26+
27+
case "$git_dir" in
28+
.git)
29+
git_dir="$orig_git/.git"
30+
;;
31+
.)
32+
git_dir=$orig_git
33+
;;
34+
esac
35+
36+
# don't link to a configured bare repository
37+
isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
38+
if test ztrue = z$isbare
39+
then
40+
die "\"$git_dir\" has core.bare set to true," \
41+
" remove from \"$git_dir/config\" to use $0"
42+
fi
43+
44+
# don't link to a workdir
45+
if test -h "$git_dir/config"
46+
then
47+
die "\"$orig_git\" is a working directory only, please specify" \
48+
"a complete repository."
49+
fi
50+
51+
# don't recreate a workdir over an existing repository
52+
if test -e "$new_workdir"
53+
then
54+
die "destination directory '$new_workdir' already exists."
55+
fi
56+
57+
# make sure the links use full paths
58+
git_dir=$(cd "$git_dir"; pwd)
59+
60+
# create the workdir
61+
mkdir -p "$new_workdir/.git" || die "unable to create \"$new_workdir\"!"
62+
63+
# create the links to the original repo. explicitly exclude index, HEAD and
64+
# logs/HEAD from the list since they are purely related to the current working
65+
# directory, and should not be shared.
66+
for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
67+
do
68+
case $x in
69+
*/*)
70+
mkdir -p "$(dirname "$new_workdir/.git/$x")"
71+
;;
72+
esac
73+
ln -s "$git_dir/$x" "$new_workdir/.git/$x"
74+
done
75+
76+
# now setup the workdir
77+
cd "$new_workdir"
78+
# copy the HEAD from the original repository as a default branch
79+
cp "$git_dir/HEAD" .git/HEAD
80+
# checkout the branch (either the same as HEAD from the original repository, or
81+
# the one that was asked for)
82+
git checkout -f $branch

gitconfig

-1
This file was deleted.

gitconfig

+262
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
[core]
2+
quotepath = false
3+
autocrlf = input
4+
[color]
5+
ui = auto
6+
[alias]
7+
# @Requires the following scripts (all available in this repo):
8+
# git-get-latest-jira-id
9+
# get-getm
10+
# git-sync-origin
11+
# git-of-interest
12+
# git-pull-request
13+
14+
## Committing
15+
##--------
16+
17+
# Commit
18+
ci = commit
19+
# Commit w/ message
20+
cim = commit -m
21+
# Amend commit
22+
cia = commit --amend
23+
# Amend commit w/message
24+
ciam = commit --amend -m
25+
# Add changed files and then commit w/message
26+
cam = commit -a -m
27+
# Commit and add files
28+
ca = commit -a
29+
# These are the same as cam, ca and squish, except it adds new files as well
30+
acam = !git add -A && git commit -m
31+
aca = !git add -A && git commit
32+
asquish = !git add -A && git commit --amend -C HEAD
33+
# Adds all changed files into the last commit
34+
squish = commit -a --amend -C HEAD
35+
# Adds only staged files into the last commit
36+
squeeze = commit --amend -C HEAD
37+
38+
# camm and cimm, acts as cam and cim aliases
39+
# but automatically creates a message using the last JIRA ticket it can find (if any)
40+
# can take one optional parameter which is the message to use after the
41+
# ticket ID (by default, this is "Source formatting")
42+
camm = "!f() { ticketId=$(git get-latest-jira-id $2); git commit -a -m \"$ticketId - ${1:-Source formatting}\"; }; f"
43+
cimm = "!f() { ticketId=$(git get-latest-jira-id $2); git commit -m \"$ticketId - ${1:-Source formatting}\"; }; f"
44+
45+
## Branches
46+
##--------
47+
48+
# Checkout
49+
co = checkout
50+
# Checkout last branch
51+
col = checkout -
52+
# Branch
53+
br = branch
54+
# create a branch by name, or if it exists, checkout the branch
55+
cb = "!f() { git checkout -b $1 2> /dev/null && echo Created new branch $1 || `git checkout $1`; }; f"
56+
# "Refreshes" the current branch (deletes the local and remote, and recreates it)
57+
refresh = "!f() { git co $(git getm) && git db-all $1; git cb $1; }; f"
58+
# Move all commits after the passed one to a new branch
59+
# eg. git split 5c29ab4 custom-feature
60+
split = "!f() { git checkout -b $2 && msg=$(git stash save) && git checkout - && git reset --hard $1 && git checkout $2 && [[ ! $msg =~ ^'No local changes to save'$ ]] && git stash pop; }; f"
61+
62+
## Merging
63+
##--------
64+
65+
# Merge
66+
mg = merge
67+
# Merge abort
68+
mga = merge --abort
69+
# Merge master into current branch
70+
mm = !git merge $(git getm)
71+
72+
## Rebasing
73+
##--------
74+
75+
# Rebase
76+
rb = rebase
77+
# Abort rebase
78+
rba = rebase --abort
79+
# Continue rebase
80+
rbc = rebase --continue
81+
# Skip patch
82+
rbs = rebase --skip
83+
# Rebase interactively
84+
rbi = rebase -i
85+
# Rebase on top of master
86+
rbm = !git rebase $(git getm)
87+
# Rebase on top of master interactively
88+
rbim = rebase -i $(git getm)
89+
90+
## Resetting
91+
##--------
92+
93+
# Reset
94+
rs = reset
95+
# Reset hard
96+
rsh = reset --hard
97+
# Reset soft
98+
rss = reset --soft
99+
100+
## Deleting
101+
##--------
102+
103+
# Delete a local branch
104+
db = branch -D
105+
# Delete a remote branch
106+
db-remote = !sh -c 'git push origin :$0'
107+
# Delete both the local and remote branches
108+
db-all = !sh -c 'git db $0 && git db-remote $0'
109+
110+
# Delete the current local branch and checkout master
111+
dbc = "!f() { local bn=$1; [[ -z $bn ]] && bn=$(git brn); master=$(git getm); [[ $bn == $master ]] && echo Cannot remove "$master" && exit; git co $master && git db $bn; }; f"
112+
113+
## Pushing
114+
##--------
115+
116+
# Syncs from upstream, then pushes the master branch to origin and upstream
117+
push-allm = "!master=$(git getm); git sync-origin $master && git push origin $master && git push upstream $master;"
118+
# Syncs from upstream, then pushes the master branch to origin and upstream
119+
push-all = "!f() { current_branch=$(git brn); git sync-origin $current_branch && git push origin $current_branch && git push upstream $current_branch; }; f"
120+
121+
pa = !git push-all
122+
pam = !git push-allm
123+
pum = push upstream $(git getm)
124+
pbo = !git push origin $(git brn)
125+
126+
pu = pull upstream
127+
fu = fetch upstream
128+
129+
## Syncing
130+
##--------
131+
132+
# Sync master from upstream to origin
133+
# This alias will stash current changes, switch to master, sync, then switch back to the original branch and apply the stash
134+
som = "!f() { local current_branch=$(git brn); local saved_index=0; local stash_save_result=`git stash save`; [[ $stash_save_result == *\"HEAD is now at\"* ]] && saved_index=1; master=$(git getm); git checkout $master && git sync-origin $master && git checkout $current_branch && ([[ $saved_index == 1 ]]) && git stash pop; }; f;"
135+
# Sync current branch with changes from upstream/master to the current branch on origin
136+
so = !git sync-origin $(git getm)
137+
# Sync current branch from upstream to origin
138+
sbo = !git sync-origin $(git brn)
139+
# Update current branch from origin
140+
ubo = !git pull origin $(git brn)
141+
142+
## Logging
143+
##--------
144+
145+
# Pretty graph
146+
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
147+
lgd = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(cyan)<%an>%Creset' --abbrev-commit --date=default
148+
# lg graph with the names of the files that have changed
149+
lgst = !git lg --stat $@
150+
# lg graph with the changes between the current branch and master
151+
lgm = !git lg $(git getm)..
152+
# lg graph with grepping on the log
153+
lgg = "!f() { git lg --grep=\"$1\"; }; f"
154+
# lg graph with searching the changes
155+
lgs = "!f() { git lg -S\"$1\"; }; f"
156+
# lg graph of just the latest commit
157+
hd = !git --no-pager log --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative -1
158+
head = !git log -n1
159+
tip = !git log --format=format:%h | head -1
160+
tipl = !git log --format=format:%H | head -1
161+
162+
## Stashing
163+
##--------
164+
165+
# Apply stash (newest by default)
166+
sa = "!f() { local stash_rev=stash@{${1:-0}}; git stash apply $stash_rev; }; f"
167+
# Pop stash (newest by default)
168+
sp = "!f() { local stash_rev=stash@{${1:-0}}; git stash pop $stash_rev; }; f"
169+
# Save stash (includes untracked files)
170+
ss = !git add . && git stash save
171+
# List all entries in the stash
172+
sl = stash list
173+
174+
## Diffing
175+
##--------
176+
177+
dt = difftool
178+
dtc = difftool --cached
179+
180+
# List the filenames and diff stats for a commit/treeish
181+
dl = "!f() { ref_spec=$(git get-custom-refspec $1); git diff --stat $ref_spec; }; f"
182+
# Show the patch for a commit/treeish
183+
delta = "!f() { ref_spec=$(git get-custom-refspec $1); git diff $ref_spec; }; f"
184+
# Show *just* the file names that have been changed for a commit/treeish
185+
ldl = "!f() { local ref_spec=$(git get-custom-refspec $1); git diff --pretty='format:' --name-only $ref_spec; }; f"
186+
187+
## Opening files
188+
##--------
189+
190+
# open batch of files
191+
bopen = "!f() { local ref_spec=$(git get-custom-refspec $1); editor=`git config --get user.editor`;files=`git diff --pretty=format: --name-only $ref_spec`;useopen=`command -v open`; usecygwin=`command -v cygstart`; [[ -n $useopen ]] && open -a \"$editor\" $files && exit $?; [[ -n $usecygwin ]] && editor=$(cygpath -d $editor); for i in $files; do echo opening $i; $usecygwin $editor $i; done }; f"
192+
# open each file individually
193+
open = "!f() { local ref_spec=$(git get-custom-refspec $1); editor=`git config --get user.editor`;files=`git diff --pretty=format: --name-only $ref_spec`;useopen=`command -v open`; usecygwin=`command -v cygstart`; [[ -n $useopen ]] && for i in $files; do echo opening $i; $useopen -a \"$editor\" $i; done && exit $?; [[ -n $usecygwin ]] && editor=$(cygpath -d $editor); for i in $files; do echo opening $i; $usecygwin $editor $i; done }; f"
194+
# Open all files that are different from master
195+
openm = !git open $(git getm)..
196+
197+
## Submodules
198+
##--------
199+
200+
# Update submodules
201+
subu = submodule update
202+
# Update submodules and initialize them
203+
subi = submodule update --init
204+
205+
## Submitting Pull Requests
206+
##--------
207+
208+
# Pull request
209+
pr = pull-request
210+
# Show pull requests w/stats
211+
prs = pull-request stat
212+
# Submit pull request and close the current one
213+
prcs = !git pr submit -q && git pr close
214+
# Sets the update branch based on the current repo directory name (so liferay-portal-ee-6.1.x will have an update branch of ee-6.1.x)
215+
set-pr-branch-config = "!f(){ git config "git-pull-request.$(git rev-parse --show-toplevel).$1" "$2"; }; f"
216+
set-update-branch = "!f(){ git set-pr-branch-config "update-branch" "${1:-$(git getm)}"; }; f"
217+
set-work-dir = "!f(){ git set-pr-branch-config "work-dir" "$1"; }; f"
218+
219+
## Misc
220+
##--------
221+
222+
# Checkout master
223+
m = !git co $(git getm)
224+
225+
# Shortcut for help
226+
h = help
227+
228+
# Cherry-pick
229+
cp = cherry-pick
230+
231+
# Get the current branch name
232+
brn = "!git branch $* | grep '^*' | sed 's/^* //'"
233+
234+
# Get the last mentioned JIRA ticket id from the commit log
235+
get-latest-jira-id = "!f() { git log $1 --oneline | grep -Eo '([A-Z]{3,}-)([0-9]+)' -m 1; }; f"
236+
237+
# Open the url to the latest JIRA ticket referenced in the log
238+
jira = "!f() { ticketId=$(git get-latest-jira-id $2); open http://issues.liferay.com/browse/$ticketId; }; f"
239+
240+
# Get a range based commit-ish based on the passed sha. Uses HEAD by default, but if a sha is passed, it creates a range
241+
# that refers to one previous. If you pass a range, it will leave it untouched so that you can customize the range yourself.
242+
# Used in many aliases
243+
# eg. git get-custom-refspec # prints HEAD^..HEAD
244+
# git get-custom-refspec ^ # prints HEAD^..
245+
# git get-custom-refspec 81c35e1 # prints 81c35e1^..81c35e1
246+
# git get-custom-refspec 5250022..master # prints 5250022..master
247+
get-custom-refspec = "!f() { to_rev=${1:-HEAD}; [[ $to_rev == ^ ]] && to_rev=HEAD^..; old_head=${to_rev}^; new_head=$to_rev; if [[ $to_rev == *..* ]]; then old_head=${to_rev%%..*}; new_head=${to_rev#*..*}; fi; ref_spec=$old_head..$new_head; echo $ref_spec; }; f"
248+
249+
# Rank contributors by number of commits
250+
stats = shortlog -s -n
251+
252+
# Same as add, but uses the verbose option since git add doesn't inform you of what exactly you just added
253+
aa = add -v
254+
255+
# List ignored files
256+
ls-ignored = ls-files --exclude-standard --ignored --others
257+
258+
# Reset last commit
259+
pop = reset HEAD^
260+
261+
# Remove untracked files and directories
262+
cln = clean -f -d

0 commit comments

Comments
 (0)