Download 4up

Transcript
git – working example
git – working example
$ mkdir wd1
$ cd wd1
wd1$ git init
Initialized empty Git repository in [...]/wd1/.git/
wd1$ ls -AF
.git/
wd1$ echo 'hello world' >file1
wd1$ git status -s
?? file1
wd1$ git add file1
wd1$ git status -s
A file1
wd1$ git commit -m 'adding my first file'
[master (root-commit) 5f3b6b2] adding my first file
1 file changed, 1 insertion(+)
create mode 100644 file1
wd1$ git log
commit 5f3b6b271a048135615805fd705adf2a89225611
Author: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Date:
Tue Nov 25 10:11:09 2014 +0000
adding my first file
wd1$ echo 'have a nice day' >>file1
wd1$ git add file1
wd1$ git commit -m 'second line added'
[master a324cdc] second line added
1 file changed, 1 insertion(+)
wd1$ git tag release-1.0 HEAD
wd1$ git log --graph --decorate --oneline
* a324cdc (HEAD, tag: release-1.0, master) second line added
* 5f3b6b2 adding my first file
wd1$ sed -i s/world/humans/ file1
wd1$ git commit -a -m 'world -> humans'
[master 610b41a] world -> humans
1 file changed, 1 insertion(+), 1 deletion(-)
wd1$ git log --graph --decorate --oneline
* 610b41a (HEAD, master) world -> humans
* a324cdc (tag: release-1.0) second line added
* 5f3b6b2 adding my first file
82
81
wd1$ git checkout updates-1.0
Switched to branch 'updates-1.0'
wd1$ sed -i 's/nice/very nice/' file1
wd1$ git commit -a -m 'nice -> very nice'
[updates-1.0 cb87e76] nice -> very nice
1 file changed, 1 insertion(+), 1 deletion(-)
wd1$ git checkout master
Switched to branch 'master'
wd1$ sed -i 's/day/day!/' file1
wd1$ git commit -a -m 'day -> day!'
[master ad469e5] day -> day!
1 file changed, 1 insertion(+), 1 deletion(-)
wd1$ git log --graph --decorate --oneline --branches
* ad469e5 (HEAD, master) day -> day!
*
152b0d0 Merge branch 'updates-1.0'
|\
* | 610b41a world -> humans
| | * cb87e76 (updates-1.0) nice -> very nice
| |/
| * c1f332c copyright notice added
|/
* a324cdc (tag: release-1.0) second line added
* 5f3b6b2 adding my first file
git – working example
wd1$ git branch
* master
wd1$ git branch updates-1.0 release-1.0
wd1$ git checkout updates-1.0
Switched to branch 'updates-1.0'
wd1$ echo "(c) `date +%Y` M. Kuhn" >>file1
wd1$ git commit -a -m 'copyright notice added'
[updates-1.0 c1f332c] copyright notice added
1 file changed, 1 insertion(+)
wd1$ git checkout master
Switched to branch 'master'
wd1$ git merge updates-1.0
Auto-merging file1
Merge made by the 'recursive' strategy.
file1 |
1 +
1 file changed, 1 insertion(+)
83
84