-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(git): add a git clone helper that automatically tracks all remot…
…e branches
- Loading branch information
Deavon M. McCaffery
committed
Aug 19, 2016
1 parent
602c12a
commit 72495ae
Showing
5 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
git-clone() { | ||
if ! test -f $(which git); then | ||
echo "Git is not available on the current path. Exiting." | ||
return | ||
fi | ||
|
||
local url=$1 | ||
local name=$2 | ||
|
||
if [ "$url" == "" ]; then | ||
echo "You must specify a url, which is the first parameter." | ||
return | ||
fi | ||
|
||
if [ "$name" == "" ]; then | ||
echo "You must specify a directory name, which is the second parameter." | ||
return | ||
fi | ||
|
||
git clone $url $name && \ | ||
cd $name && \ | ||
git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /\/develop$/d; /remotes/p;" | xargs -L1 git checkout -t 2>/dev/null && \ | ||
git init -d 2>/dev/null | ||
|
||
echo Checking out master and develop branches... | ||
|
||
git checkout develop 2>/dev/null | ||
git checkout master 2>/dev/null | ||
} | ||
|
||
clone() { | ||
git-clone $@ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
function source-uname() { | ||
for f in ~/.ssh/scripts/$(uname)/*; do | ||
source $f | ||
done | ||
function source-uname() { | ||
local unamepath=~/.ssh/scripts/$(uname) | ||
|
||
if test -d $unamepath; then | ||
for f in $unamepath/*; do | ||
source $f | ||
done | ||
fi | ||
} | ||
|
||
source-uname |