Uživatelské nástroje

Nástroje pro tento web


git:quickstart

Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.

Odkaz na výstup diff

Obě strany předchozí revizePředchozí verze
Následující verze
Předchozí verze
git:quickstart [2016/01/05 13:49] nost23git:quickstart [2016/04/13 16:10] (aktuální) – upraveno mimo DokuWiki 127.0.0.1
Řádek 1: Řádek 1:
 +====== QUICKSTART / VSEHOCHUT ======
 +===== .GITIGNORE =====
 +ignorovani preskakovani
 +podle souboru .gitignore v root repa ignoruje soubory
 +<code bash>
 +/.htaccess
 +/vendor/
 +/temp/cache/
 +*.png
 +*.jpg
 +</code>
  
 +===== NASTAVENI DEFAULT JMENA =====
 +<code bash>
 +$ git config --global user.name "name"
 +$ git config --global user.email "name"
 +$ git config --global color.ui true
 +</code>
 +
 +===== NASTAVENI DEFAULT VETVE =====
 +<code bash>
 +$ git push --set-upstream NAS moduly
 +</code>
 +
 +===== LOG =====
 +<code bash>
 +$ git status
 +$ git log
 +</code>
 +
 +===== ADD =====
 +stage new files,changes/deletions
 +<code bash>
 +$ git add <soubor/y/bash nahrazeni>
 +$ git interactive # loop kde se pta na jednotlive soubory
 +</code>
 +
 +===== COMMIT =====
 +<code bash>
 +$ git add <file>|--all|*\.cpp
 +$ git commit [-m "message"]
 +</code>
 +
 +Re-push amended commitu [se zachovanim historie]:
 +<code bash>
 +...
 +$ git commit -amend
 +$ git pull
 +# manualy merge if needed
 +$ git push
 +</code>
 +
 +===== UPLOAD =====
 +==== bundle archiv ====
 +<code bash>
 +$ git bundle create /file/name --all
 +</code>
 +
 +<code bash>
 +$ git archive [--remote=<repo>] --format zip --output /full/path/to/zipfile.zip master
 +$ git archive master | bzip2 >source-tree.tar.bz2
 +</code>
 +==== zkopirovani jinam,nezkomprimovane ====
 +<code bash>
 +$ git archive [--remote=<repo>] master | tar -x -C /somewhere/else
 +</code>
 +===== VRACENI MINULOSTI SOUBORU =====
 +==== pro jednoho ====
 +<code bash>
 +$ git checkout [commit nebo nic pro posledni] -- cesta/k/souboru
 +</code>
 +==== zpet commit ====
 +jeden
 +<code bash>
 +$ git revert [commit]
 +</code>
 +
 +vice
 +<code bash>
 +$ git revert --no-commit D
 +$ git revert --no-commit C
 +$ git revert --no-commit B
 +$ git commit [-m 'the commit message']
 +</code>
 +==== odstraneni souboru z minuleho commitu ====
 +<WRAP info>
 +necha soubor na disku jak je
 +</WRAP>
 +<code bash>
 +$ git reset HEAD^ cesta/k/souboru
 +</code>
 +===== BRANCH =====
 +branching == vetveni
 +
 +==== vypis ====
 +<code bash>
 +$ git branch
 +</code>
 +
 +==== vypis zmergovani do aktualni - bez hvezdicky jsou nepouzivane,uz pretazene ====
 +<code bash>
 +$ git branch --merged
 +</code>
 +==== vypis jeste nezmergovanych ====
 +<code bash>
 +$ git branch --no-merged
 +</code>
 +==== vytvoreni nove+prepnuti ====
 +<code bash>
 +$ git checkout -b <nova vetev>
 +$ git checkout -b <nova vetev> <server>/<vetev>
 +$ git checkout --track <server>/<vetev> # nastavi na trackovani vzdalene vetve aktualni vetev
 +</code>
 +nebo
 +<code bash>
 +$ git branch <nova vetev>
 +$ git checkout <nova vetev>
 +</code>
 +==== prepnuti ====
 +[automaticky zmeni soubory v pracovnim adresari,pokud chceme tahat mezi vetvemi # git pull ? ]
 +<code bash>
 +$ git checkout <vetev>
 +</code>
 +==== trackovani vetve i na origin ====
 +<code bash>
 +$ git push -u origin vetev
 +</code>
 +==== smazani ====
 +<code bash>
 +$ git branch -d <vetev>
 +$ git push [remotename] :[branch] # maze vzdalene vetve, z nic udelej tohle a je to ?
 +</code>
 +
 +===== TAG =====
 +Vice druhu:
 +  * anotovany [ -a ]
 +  * podepsany [ -s -u <soubor s klicem> ]
 +  * bez infa - ''lightweight'' [ zadna volba ]
 +
 +==== vypis ====
 +<code bash>
 +$ git tag [ -l <hledany vyraz> ]
 +</code>
 +==== vytvoreni ====
 +na commit, staci jen 7 znaku ze sha1 commitu
 +<code bash>
 +$ [ GIT_COMMITTER_DATE="2014-04-14 14:26:00" ] git tag [-a|-s|-u] <tag,v0.1> <sha z commitu> [ -m "zprava" ]
 +</code>
 +==== odstraneni ====
 +<code bash>
 +$ git tag -d <jmeno>
 +</code>
 +==== a finalne ====
 +<code bash>
 +$ git push --tags NAS/master
 +</code>
 +
 +===== DIFF =====
 +GUI pokud mame Kompare, Meld
 +<code bash>
 +$ git difftool
 +</code>
 +nebo
 +<code bash>
 +$ git diff [--staged]
 +</code>
 +
 +===== 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
 +<code bash>
 +$ git checkout <kam/vetsinou master>
 +$ git mergetool <vetev>
 +</code>
 +a vybrat
 +nebo
 +<code bash>
 +$ git checkout <kam/vetsinou master>
 +$ git merge <vetev>
 +$ git status 
 +</code>
 +Sekce unmerged files, vklada do textu automaticky "zarazky" a rucne
 +
 +===== PATCH =====
 +vyhazi soubory .patch od kazdeho commitu
 +<code bash>
 +$ git format-patch <tag>
 +</code>
 +
 +===== ADD ORIGIN [CENTRAL COPY] =====
 +pridani vzdaleneho
 +<code bash>
 +$ git remote add origin git@git.sh.cvut.cz:repo.git
 +$ git remote -v
 +</code>
 +
 +===== UPDATE ORIGIN [CENTRAL COPY] =====
 +==== stahne zmeny ====
 +<code bash>
 +$ git fetch <jmeno,origin|NAS>
 +</code>
 +==== nahraje zmeny ====
 +<code bash>
 +$ git push <remotename,origin|NAS> <vetev>
 +$ git push [remotename] [localbranch]:[remotebranch] # to same akorat na serveru je jine jmeno vetve
 +</code>