mkdir alpha
cd alpha
echo "hello" > world.txt
git init
git status
git add world.txt
git status
git commit -m "Initial commit"
git status
git log
git log --all --oneline --graph --decorate
git config --global alias.lg "log --all --oneline --graph --decorate"
git lg
https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig
echo "world" >> world.txt
git status
git add world.txt
git commit -m "Added world to world.txt"
git status
git lg
cat world.txt
git checkout HEAD~1
git lg
cat world.txt
git checkout master
git lg
cat world.txt
echo "blabla" >> world.txt
cat world.txt
git checkout world.txt
cat world.txt
git status
cd ..
git clone alpha beta
cd beta
ls
git lg
cd ../alpha
echo "print 'hello world'" > hello.py
git add hello.py
git commit -m "Added hello.py initial version"
git lg
cd ../beta
git lg
git fetch
git lg
git merge
# git fetch + git merge = git pull
git lg
ls
cd ..
git clone --bare alpha common.git
cd common.git
ls
cd ..
git clone common.git gamma
cd gamma
ls
cd ../alpha
git remote add origin ../common.git
git push -u origin master
git lg
cd ../beta
git remote -v
git remote remove origin
git remote add origin ../common.git
git push -u origin master
git lg
cd ..
git clone --bare alpha common.git
cd common.git
ls
cd ..
git clone common.git gamma
cd gamma
ls
cd ../alpha
git remote add origin ../common.git
git push -u origin master
git lg
cd ../beta
git remote -v
git remote remove origin
git remote add origin ../common.git
git push -u origin master
git lg
echo "Tiger" > cats.txt
git add cats.txt
git commit -m "Added cats.txt - a list of cat names"
git fetch
git lg
git push
git lg
cd ../alpha
echo "Fido" > dogs.txt
git add dogs.txt
git commit -m "Added dogs.txt - a list of dog names"
git fetch
git lg
git merge origin/master --no-edit
git lg
# for å "angre" merge vi gjorde:
git reset --keep HEAD~1
git lg
# git stash
git rebase origin/master
# git stash pop
git lg
git push
git lg
# git stash og git stash pop brukes
# dersom man har filer man har endret
# men ikke vil committe
echo "Fluffy" >> cats.txt
git commit -am "Added Fluffy to list of cat names"
git push
cd ../beta
echo "Shadow" >> cats.txt
git commit -am "Added Shadow to list of cat names"
git pull
nano cats.txt
git add cats.txt
git commit -m "Merged list of cat names"
git lg
# igjen, for å "angre" merge vi gjorde:
git reset --keep HEAD~1
git fetch
git rebase
nano cats.txt
git add cats.txt
git rebase --continue
git lg
git push
git checkout -b fancyhello
echo "print sum(range(1, 101))" >> hello.py
git commit -am "Math demo added to hello.py"
git lg
git checkout master
echo "Bo" >> dogs.txt
git commit -am "Added dog name Bo"
git lg
git checkout fancyhello
git rebase master
git checkout master
git merge fancyhello
GitHub sin interaktive intro til Git:
Interaktiv tutorial til mer avansert branching og rebasing:
http://pcottle.github.io/learnGitBranching/
En fin liste med nyttige Git-kommandoer:
Hvordan bruke Git til å enkelt oppdatere en nettside ("push-to-deploy"):
http://toroid.org/ams/git-website-howto
Artikkel om hvordan Git faktisk fungerer:
Mine alias
unstage = reset HEAD
preview = diff --cached
lg = !git --no-pager lgl -15
lgl = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
st = status -s
co = checkout
wdiff = diff --color-words
# Remove the old tag with this name and tag the latest commit with it.
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"
alias = !git config --list | fgrep alias. | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort | cut -c -80