Skip to content

Commit

Permalink
feat(git): add shortcut for initializing git repos the right way
Browse files Browse the repository at this point in the history
  • Loading branch information
Deavon McCaffery committed Aug 19, 2016
1 parent 3901fd9 commit 7ae4f5c
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 12 deletions.
17 changes: 8 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fi
LOCAL_PREFIX=/usr/local

if test "$(uname)" = "Darwin"; then
if ! type brew 2>/dev/null; then
if ! type brew 1>/dev/null 2>&1; then
success "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
Expand All @@ -63,23 +63,22 @@ if test "$(uname)" = "Darwin"; then
done

rm -rf "$LOCAL_PREFIX/etc/bash_completion.d/git-prompt.sh" 1>/dev/null
rm -rf "$LOCAL_PREFIX/etc/bash_completion.d/git-flow-completion.bash" 1>/dev/null

for pkg in git git-extras git-flow-avh gnu-getopt homebrew/versions/node5 openssl; do
for pkg in openssl git git-extras git-flow-avh node; do
if brew list -1 | grep -q "^${pkg}\$"; then
success "Upgrading $pkg..."
brew upgrade ${pkg} 1>/dev/null
brew link --overwrite ${pkg}
brew upgrade ${pkg} 1>/dev/null 2>&1
brwe link --overwrite ${pkg} 1>/dev/null 2>&1
else
success "Installing $pkg..."
brew install ${pkg}
fi
done

git config --system credential.helper osxkeychain

success "Tapping extended versions for caskroom..."
brew tap caskroom/versions 1>/dev/null

success "Setting git credential helper to use the macOS keychain..."
git config --system credential.helper osxkeychain 1>/dev/null

elif test "$(uname)" = "MINGW64_NT-10.0"; then
LOCAL_PREFIX=$LOCALAPPDATA/git

Expand Down
101 changes: 101 additions & 0 deletions src/git/gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# normalize line endings
* text=auto

# use c# diff for .cs files
*.cs text diff=csharp

# force conflict resolution of project files
*.sln text eol=crlf merge=union
*.csproj text merge=union
*.vbproj text merge=union
*.vcxproj text merge=union
*.vcproj text merge=union
*.dbproj text merge=union
*.fsproj text merge=union
*.lsproj text merge=union
*.wixproj text merge=union
*.modelproj text merge=union
*.sqlproj text merge=union
*.wwaproj text merge=union

# xcode project files are unioned as binary files
*.pbxproj binary merge=union

# known binary files are treated as binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.pyc binary
*.pdf binary

# documentation
*.md text
LICENSE text
AUTHORS text

# known plain text files are treated as plain text
*.doc text diff=astextplain
*.DOC text diff=astextplain
*.docx text diff=astextplain
*.DOCX text diff=astextplain
*.dot text diff=astextplain
*.DOT text diff=astextplain
*.pdf text diff=astextplain
*.PDF text diff=astextplain
*.rtf text diff=astextplain
*.RTF text diff=astextplain

# git/tfvc config
.gitattributes text
.gitignore text
.tfignore text

# web source file types
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text

# nuget files
.nuspec text

# config files
.config text

# windows files
*.cmd text eol=crlf
*.bat text eol=crlf
*.txt text eol=crlf
*.ini text eol=crlf
*.ps1 text eol=crlf
*.psm1 text eol=crlf
*.psd1 text eol=crlf

# unix files
*.sh text eol=lf
122 changes: 122 additions & 0 deletions src/git/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# user files
*.user
*.suo

# build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Tt]arget/
x64/
x86/
[Bb]in/
[Oo]bj/
[Aa]rtifacts/

# package manager artifacts
[Pp]ackages/
[Nn]ode_[Mm]odules/
[Bb]ower_[Cc]omponents/

# visual studio 2015 cache/options
[Pp]roject.lock.json
[Cc]ondo.[Aa]ssembly[Ii]nfo.cs

# ria/silverlight projects
Generated_Code/

# sql server files
*.mdf
*.ndf
*.ldf

# jetbrains
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
_TeamCity*
*.dotCover

# include solution based resharper settings
!*.[Dd]ot[Ss]ettings

# stylecop
[Ss]tyle[Cc]op.[Cc]ache

# mstest results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
[Bb]uild.[Ll]og

# business intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# microsoft fakes
FakesAssemblies/

# azure build output
csx/
*.build.csdef

# windows store app package directory
AppPackages/

# nuget exe
nuget.exe

# nuget packages
*.nupkg

# include msbuild targets in nuget
!**/packages/**/build/

# include repositories.config for nuget
!**/packages/repositories.config

# include config file for nuget
![Nn]u[Gg]et.config

# include self (tfignore)
!.tfignore
!.gitignore
!.gitattributes

# mac files
.DS_Store

# win files
[Tt]humbs.db

# log files
*.log

# tsd
[Tt]sd/
_tsd
tsd
tsd.cmd

# mocha
_mocha
mocha
mocha.cmd

# bower
bower
_bower
bower.cmd

# gem
[Gg]emfile.lock

# docs
vnd/

# hidden folders
.*/

# condo files
Condo.AssemblyInfo.cs
41 changes: 38 additions & 3 deletions src/scripts/git-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if test -n "${UBER_DEBUG+1}"; then
fi

git-clone() {
if ! test -f $(which git); then
if ! type git 1>/dev/null 2>&1; then
echo "Git is not available on the current path. Exiting."
return
fi
Expand All @@ -21,8 +21,8 @@ git-clone() {
return
fi

git clone $url $name && \
cd $name && \
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

echo Checking out master and develop branches...
Expand All @@ -36,4 +36,39 @@ git-clone() {

clone() {
git-clone $@
}

git-init() {
if ! type git 1>/dev/null 2>&1; then
echo "Git is not available on the current path. Exiting."
return
fi

local name=$1

if test -z "$name"; then
name="."
fi

# initialize a new repo
git init "$name"

# change directory into the new repo
cd "$name"

# create an initial empty commit
git commit --allow-empty -m "initial commit" 1>/dev/null

# initialize git flow
git flow init -d 1>/dev/null

# copy the default gitignore and gitattributes
cp ~/.uber/git/gitignore .gitignore 1>/dev/null
cp ~/.uber/git/gitattributes .gitattributes 1>/dev/null

# add the newly created gitignore and gitattributes
git add . 1>/dev/null

# create the initial commit
git commit -m "chore: add git ignore and attributes" 1>/dev/null
}

0 comments on commit 7ae4f5c

Please sign in to comment.