Skip to content

Commit a89e96d

Browse files
committed
fix win vs mac
1 parent 9a09d30 commit a89e96d

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ It calls a script that sets git configurations for a project (or globally)<br />
2121
<strong>git-sample-repo-create.ps1</strong> is a PowerShell script that
2222
creates a repository on your local clones your fork of a sample sample repository.
2323

24-
All these scripts create a folder, but that folder is deleted at the beginning of each run.
24+
All these scripts create a folder, but that folder is deleted at the beginning of each run
25+
to make them "idempotent" in that each run of the script ends up in the same condition,
26+
whether run the first time or subsequent times.
27+
28+
The scripts contain an <strong>exit</strong> after each set of steps
29+
so you can examine the impact of the whole sequence of commands.
30+
31+
Additionally, diagrams (animated step-by-step in PowerPoint) have been prepared to illustrate the flow and sequence of commands.
2532

2633
Enjoy!

git-sample-repo-create.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ $NOW = Get-Date -Format "yyyy-MM-ddTHH:mmzzz"
3636
echo "IsWindows=$IsWindows"
3737
echo "IsOSX=$IsOSX"
3838
echo "IsLinux=$IsLinux"
39-
#if [ "$IsWindows" ]; then
40-
#fi
4139
git --version
4240

4341
exit #1
@@ -46,7 +44,7 @@ git --version
4644
$REPONAME='git-sample-repo'
4745

4846
echo "******** STEP Delete $REPONAME remnant from previous run:"
49-
$FileExists = Test-Path $REPONAME
47+
$FileExists = Test-Path $REPONAME
5048
if ($FileExists -eq $True ){
5149
# See https://technet.microsoft.com/en-ca/library/hh849765.aspx?f=255&MSPPError=-2147217396
5250
Remove-Item -path ${REPONAME} -Recurse -Force # instead of rm -rf ${REPONAME}

git-sisters-update.ps1

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# git-sisters-update.ps1 from within http://github.com/wilsonmar/git-utilities.
22
# by Wilson Mar ([email protected], @wilsonmar)
33

4-
# This script was created for experiementing and learning Git.
4+
# This script was created for experiementing and learning Git with GitHub.
55
# Git commands in this script are meant as examples for manual entry
66
# explained during my live "Git and GitHub" tutorials and
77
# explained at https://wilsonmar.github.io/git-commands-and-statuses/).
@@ -21,6 +21,8 @@
2121
# Sample call in MacOS running PowerShell for Mac:
2222
# chmod +x git-sisters-update.ps1
2323
# ./git-sisters-update.ps1
24+
# results in "Add " as branch name. Alternately, run script with your own branch:
25+
# ./git-sisters-update.ps1 "Add year 1979"
2426

2527
# Last tested on MacOS 10.12 (Sierra) 2015-11-29
2628
# http://skimfeed.com/blog/windows-command-prompt-ls-equivalent-dir/
@@ -171,10 +173,17 @@ if (Test-Path ".gitignore"){
171173
# exit #4
172174

173175

174-
# Run another script file to define git configuration at the repo level:
175-
Invoke-Expression "./git_client-config.ps1"
176+
echo "******** Run PowerShell file for Git configurations at the repo level:"
177+
$ScriptPath = Split-Path $MyInvocation.InvocationName
178+
Write-Host "Path:" $MyInvocation.MyCommand.Path
179+
# NOTE: PowerShell accepts both forward and backward slashes:
180+
& ((Split-Path $MyInvocation.InvocationName) + '/git_client-config.ps1')
181+
# Alternately, use & to run scripts in same scope:
182+
# & "../git_client-config.ps1 global" #
183+
# Alternately, use . to run scripts in child scope that will be thrown away:
184+
# . "../git_client-config.ps1 global" #
176185

177-
# exit #5
186+
exit #5
178187

179188
cd ${REPONAME}
180189
$CurrentDir = $(get-location).Path;
@@ -244,7 +253,12 @@ git l -10
244253
echo "******** git checkout master branch:"
245254
git checkout master
246255

247-
$CURRENT_BRANCH="feature1"
256+
# Default is local:
257+
if( $args[0] -eq "" ) {
258+
$CURRENT_BRANCH="feature1"
259+
}else{
260+
$CURRENT_BRANCH=$args[0]
261+
}
248262
echo "******** git checkout new branch $CURRENT_BRANCH from master branch :"
249263
git checkout -b $CURRENT_BRANCH
250264
git branch -avv
@@ -265,7 +279,7 @@ sisters_new_meta_file Mimi true "boots"
265279
echo "******** git status : before git add :"
266280
git status
267281
echo "******** git add :"
268-
git add photo-info.md bebe.md heather.md laurie.md mimi.md
282+
git add . # photo-info.md bebe.md heather.md laurie.md mimi.md
269283
echo "******** git status : after git add "
270284
git status
271285
echo "******** git commit of $CURRENT_YEAR (new commit SHA) :"

git_client-config.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
# for running under PowerShell on Mac or Windows
33
# See https://www.develves.net/blogs/asd/articles/using-git-with-powershell-on-windows-10/
44

5+
# Default is local:
6+
if( $args[0] -eq "global" ) {
7+
$GIT_GLOBAL = "--global"
8+
}else{
9+
$GIT_GLOBAL = "" # local
10+
}
11+
512
echo "******** Running script file git_client-config.ps1"
613
# Change string from "" to "--global"
7-
$GIT_GLOBAL = "" # "--global"
814
if( $GIT_GLOBAL -eq "--global" ) {
9-
echo "******** Updating $GIT_GLOBAL repo using git config commands"
15+
echo "******** Creating $GIT_GLOBAL repo in $HOME home dir using git config commands"
1016
}else{
11-
echo "******** Updating local ../.git/config file using git config commands"
17+
echo "******** Creating local ../.git/config file using git config commands"
1218
}
1319

20+
1421
# TODO: Create separate shell file to define git aliases for repo.
1522
# Verify settings:
1623
git config $GIT_GLOBAL core.filemode false

0 commit comments

Comments
 (0)