Created
July 16, 2010 17:57
-
-
Save zerowidth/478679 to your computer and use it in GitHub Desktop.
git demo of what happens when you try to push to a working copy
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
#!/bin/sh | |
# try out cloning and pushing using a working copy in git | |
# | |
function log() { | |
echo | |
echo "***** $1" | |
echo | |
} | |
log "cleaning up" | |
rm -rfv git_funky/ 1>/dev/null | |
log "ok here we go" | |
mkdir git_funky | |
cd git_funky | |
log "new working copy..." | |
mkdir working | |
cd working | |
git init | |
echo "one" >> foo.txt | |
echo "two" >> foo.txt | |
echo "three" >> foo.txt | |
git add foo.txt | |
git commit -m "adding foo" | |
echo "four" >> foo.txt | |
git commit -am "adding four to foo" | |
log "ok, working copy is in place, with 'history'" | |
git log --pretty=oneline | |
cd ../ | |
log "cloning from working copy" | |
git clone working/.git copy | |
cd copy | |
log "we've got a clone in copy/ now:" | |
git show | |
log "ok, now make some changes in the working copy, but don't commit them" | |
cd ../working | |
echo "first | |
second | |
third | |
fourth" > foo.txt | |
git diff | |
log "now make a similar change in the clone, then push it back to the working copy" | |
cd ../copy | |
echo "uno | |
dos | |
three | |
four" > foo.txt | |
git ci -am "spanish lol" | |
git push | |
log "kaboom! so now enable that in the working copy, just to see" | |
cd ../working | |
git config receive.denyCurrentBranch warn | |
cd ../copy | |
git push | |
log "now look at the diff in the working copy..." | |
cd ../working | |
git diff | |
log "whoa crazy, that looks fine. what happened to uno, dos?" | |
git diff --cached | |
log "neat, it's in the index... so what happens if i do it again?" | |
cd ../copy | |
echo "five" >> foo.txt | |
git ci -am "adding five!" | |
git push | |
cd ../working | |
git diff | |
git diff --cached |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment