Skip to content

Instantly share code, notes, and snippets.

@kgadek
Created February 9, 2015 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgadek/b0dab494ca8a07c5e5b7 to your computer and use it in GitHub Desktop.
Save kgadek/b0dab494ca8a07c5e5b7 to your computer and use it in GitHub Desktop.
git subtree
bash-3.2$ git init subproj_remote
Initialized empty Git repository in /Users/konrad/tmp/arz-sub2/subproj_remote/.git/
bash-3.2$ git init project
Initialized empty Git repository in /Users/konrad/tmp/arz-sub2/project/.git/
bash-3.2$ cd project
bash-3.2$ echo "PROJECT : inicjacja projektu" >> CHANGELOG
bash-3.2$ git add CHANGELOG
bash-3.2$ git commit -m 'Projekt: pierwszy'
[master (root-commit) 2fc53c2] Projekt: pierwszy
1 file changed, 1 insertion(+)
create mode 100644 CHANGELOG
bash-3.2$ git checkout ../subproj_remote
fatal: ../subproj_remote: '../subproj_remote' is outside repository
bash-3.2$ cd ../subproj_remote
bash-3.2$ echo "SUBPROJ : inicjacja projektu" >> CHANGELOG
bash-3.2$ echo "somecodeblabla" >> CODE1.wtf
bash-3.2$ echo "someothercodeblabla" >> CODE2.wtf
bash-3.2$ git add *
bash-3.2$ git commit -m 'SUBPROJ : trochę kodu'
[master (root-commit) b911593] SUBPROJ : trochę kodu
3 files changed, 3 insertions(+)
create mode 100644 CHANGELOG
create mode 100644 CODE1.wtf
create mode 100644 CODE2.wtf
bash-3.2$ cd ../project
bash-3.2$ echo "poproszę kilogram Haskella" >> CODE.lol
bash-3.2$ echo "ależ proszę, oto kilogram Haskella" >> EDOC.lol
bash-3.2$ git add *
bash-3.2$ git commit -m 'PROJECT : i tutaj też trochę kodu'
[master 18f9bb4] PROJECT : i tutaj też trochę kodu
2 files changed, 2 insertions(+)
create mode 100644 CODE.lol
create mode 100644 EDOC.lol
bash-3.2$ # TUTAJ SCREENSHOT 1: https://www.dropbox.com/s/ygpmnuu61c5af3f/Zrzut%20ekranu%202015-02-09%2013.32.23.png?dl=0
bash-3.2$ pwd
/Users/konrad/tmp/arz-sub2/project
bash-3.2$ git remote add subproj_remote ../subproj_remote
bash-3.2$ git fetch subproj_remote
...(Konrad) snip...
From ../subproj_remote
* [new branch] master -> subproj_remote/master
bash-3.2$ git subtree add --prefix subproj subproj_remote master
git fetch subproj_remote master
From ../subproj_remote
* branch master -> FETCH_HEAD
Added dir 'subproj'
bash-3.2$ # TUTAJ SCREENSHOT 2: https://www.dropbox.com/s/d9ob86dkwp5r44w/Zrzut%20ekranu%202015-02-09%2013.34.52.png?dl=0
bash-3.2$ ls *
CHANGELOG CODE.lol EDOC.lol
subproj:
CHANGELOG CODE1.wtf CODE2.wtf
bash-3.2$ cat CHANGELOG
PROJECT : inicjacja projektu
bash-3.2$ cat subproj/CHANGELOG
SUBPROJ : inicjacja projektu
bash-3.2$ cd ../subproj_remote/
bash-3.2$ cd ../subproj_remote
bash-3.2$ ls *
CHANGELOG CODE1.wtf CODE2.wtf
bash-3.2$ echo "więcej kodu?" >> CODE3.wtf
bash-3.2$ echo "jestę kodę, uświadom to sobie sobie" >> CODE4.wtf
bash-3.2$ echo "jakiś fix" >> CODE1.wtf
bash-3.2$ git add *
bash-3.2$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
mmodified: CODE1.wtf
mnew file: CODE3.wtf
mnew file: CODE4.wtf
bash-3.2$ git commit 'SUBPROJ : aktualizacja'
error: pathspec 'SUBPROJ : aktualizacja' did not match any file(s) known to git.
bash-3.2$ git commit -m 'SUBPROJ : aktualizacja'
[master b23660c] SUBPROJ : aktualizacja
3 files changed, 3 insertions(+)
create mode 100644 CODE3.wtf
create mode 100644 CODE4.wtf
bash-3.2$ cd ../project
bash-3.2$ git fetch subproj_remote
...(Konrad) snip...
From ../subproj_remote
b911593..b23660c master -> subproj_remote/master
bash-3.2$ git fetch subproj_remote master
From ../subproj_remote
* branch master -> FETCH_HEAD
bash-3.2$ # SCREENSHOT 3: https://www.dropbox.com/s/u60y4ma3yvl3hpf/Zrzut%20ekranu%202015-02-09%2013.38.33.png?dl=0
bash-3.2$ git subtree pull --prefix subproj subproj_remote master
From ../subproj_remote
* branch master -> FETCH_HEAD
...(Konrad) tutaj podałem commit message w vim...
".git/MERGE_MSG" 7L, 283C zapisano
Merge made by the 'recursive' strategy.
subproj/CODE1.wtf | 1 +
subproj/CODE3.wtf | 1 +
subproj/CODE4.wtf | 1 +
3 files changed, 3 insertions(+)
create mode 100644 subproj/CODE3.wtf
create mode 100644 subproj/CODE4.wtf
bash-3.2$ ls *
CHANGELOG CODE.lol EDOC.lol
subproj:
CHANGELOG CODE1.wtf CODE2.wtf CODE3.wtf CODE4.wtf
bash-3.2$ # SCREENSHOT 4: https://www.dropbox.com/s/ek48ckqqbjtv4s1/Zrzut%20ekranu%202015-02-09%2013.39.59.png?dl=0
bash-3.2$ cd subproj
bash-3.2$ ls *
CHANGELOG CODE1.wtf CODE2.wtf CODE3.wtf CODE4.wtf
bash-3.2$ echo "that was ugly. Czas an coś normalnego. I z czeskimi błędami" >> CODE3.wtf
bash-3.2$ echo "CZESKIE BĘŁDY" >> CHANGELOG
bash-3.2$ git add *
bash-3.2$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
mmodified: CHANGELOG
mmodified: CODE3.wtf
bash-3.2$ git commit -m 'niby SUBPROJ ale z PROJ: czeski !'
[master 5b4fca6] niby SUBPROJ ale z PROJ: czeski !
2 files changed, 2 insertions(+)
bash-3.2$ # SCREENSHOT 5: https://www.dropbox.com/s/g7uh0laz386ou6u/Zrzut%20ekranu%202015-02-09%2013.42.00.png?dl=0: https://www.dropbox.com/s/o0rrwvaw6pp0g1i/Zrzut%20ekranu%202015-02-09%2013.44.24.png?dl=0
bash-3.2$ git subtree push --prefix subproj subproj_remote master
You need to run this command from the toplevel of the working tree.
bash-3.2$ cd ..
...(Konrad) tutaj był błąd zw. z tym, że mój `remote` był lokalny i nie do końca git-owi podobało się,
że mu zmieniam mastera na żywca. Ma sens. Normalnie, w wypadku repozytoriów zewn., nie będzie
tego problemu
...
bash-3.2$ # ohokay, tego problemu nie będzie normalnie. chwila
bash-3.2$ cd ../subproj_remote
bash-3.2$ git branch SOMETEMPBRANCH
bash-3.2$ git checkout SOMETEMPBRANCH
Switched to branch 'SOMETEMPBRANCH'
bash-3.2$ cd ../project
bash-3.2$ git subtree push --prefix subproj subproj_remote master
...(Konrad) snip...
To ../subproj_remote
b23660c..b749bc2 b749bc22be744823c3356fe95c02d435f006d334 -> master
bash-3.2$ # SCREENSHOT 6: https://www.dropbox.com/s/o0rrwvaw6pp0g1i/Zrzut%20ekranu%202015-02-09%2013.44.24.png?dl=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment