====== QUICKSTART / VSEHOCHUT ====== ===== .GITIGNORE ===== ignorovani preskakovani podle souboru .gitignore v root repa ignoruje soubory /.htaccess /vendor/ /temp/cache/ *.png *.jpg ===== NASTAVENI DEFAULT JMENA ===== $ git config --global user.name "name" $ git config --global user.email "name" $ git config --global color.ui true ===== NASTAVENI DEFAULT VETVE ===== $ git push --set-upstream NAS moduly ===== LOG ===== $ git status $ git log ===== ADD ===== stage new files,changes/deletions $ git add $ git interactive # loop kde se pta na jednotlive soubory ===== COMMIT ===== $ git add |--all|*\.cpp $ git commit [-m "message"] Re-push amended commitu [se zachovanim historie]: ... $ git commit -amend $ git pull # manualy merge if needed $ git push ===== UPLOAD ===== ==== bundle archiv ==== $ git bundle create /file/name --all $ git archive [--remote=] --format zip --output /full/path/to/zipfile.zip master $ git archive master | bzip2 >source-tree.tar.bz2 ==== zkopirovani jinam,nezkomprimovane ==== $ git archive [--remote=] master | tar -x -C /somewhere/else ===== VRACENI MINULOSTI SOUBORU ===== ==== pro jednoho ==== $ git checkout [commit nebo nic pro posledni] -- cesta/k/souboru ==== zpet commit ==== jeden $ git revert [commit] vice $ git revert --no-commit D $ git revert --no-commit C $ git revert --no-commit B $ git commit [-m 'the commit message'] ==== odstraneni souboru z minuleho commitu ==== necha soubor na disku jak je $ git reset HEAD^ cesta/k/souboru ===== BRANCH ===== branching == vetveni ==== vypis ==== $ git branch ==== vypis zmergovani do aktualni - bez hvezdicky jsou nepouzivane,uz pretazene ==== $ git branch --merged ==== vypis jeste nezmergovanych ==== $ git branch --no-merged ==== vytvoreni nove+prepnuti ==== $ git checkout -b $ git checkout -b / $ git checkout --track / # nastavi na trackovani vzdalene vetve aktualni vetev nebo $ git branch $ git checkout ==== prepnuti ==== [automaticky zmeni soubory v pracovnim adresari,pokud chceme tahat mezi vetvemi # git pull ? ] $ git checkout ==== trackovani vetve i na origin ==== $ git push -u origin vetev ==== smazani ==== $ git branch -d $ git push [remotename] :[branch] # maze vzdalene vetve, z nic udelej tohle a je to ? ===== TAG ===== Vice druhu: * anotovany [ -a ] * podepsany [ -s -u ] * bez infa - ''lightweight'' [ zadna volba ] ==== vypis ==== $ git tag [ -l ] ==== vytvoreni ==== na commit, staci jen 7 znaku ze sha1 commitu $ [ GIT_COMMITTER_DATE="2014-04-14 14:26:00" ] git tag [-a|-s|-u] [ -m "zprava" ] ==== odstraneni ==== $ git tag -d ==== a finalne ==== $ git push --tags NAS/master ===== DIFF ===== GUI pokud mame Kompare, Meld $ git difftool nebo $ git diff [--staged] ===== MERGE ===== Je vice druhu: * fast-forward [jen presune pointer] * three-way diff [prvni,druhy,spolecny predek] * manual - pokud vyse uvedene selzou GUI pokud mame Kompare, Meld $ git checkout $ git mergetool a vybrat nebo $ git checkout $ git merge $ git status Sekce unmerged files, vklada do textu automaticky "zarazky" a rucne ===== PATCH ===== vyhazi soubory .patch od kazdeho commitu $ git format-patch ===== ADD ORIGIN [CENTRAL COPY] ===== pridani vzdaleneho $ git remote add origin git@git.sh.cvut.cz:repo.git $ git remote -v ===== UPDATE ORIGIN [CENTRAL COPY] ===== ==== stahne zmeny ==== $ git fetch ==== nahraje zmeny ==== $ git push $ git push [remotename] [localbranch]:[remotebranch] # to same akorat na serveru je jine jmeno vetve