Zubeginn ist alles leer (Working directory & Index):
$ git status # On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track)
$ git ls-files --debug -s
Anlegen eines zweier files, wovon eins in den Index kommt (stage)
$ touch unused $ touch foo $ git add foo
$ git commit -a -m "Added foo" [master (root-commit) 5f3450e] Added foo 0 files changed create mode 100644 foo
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused nothing added to commit but untracked files present (use "git add" to track)
$ git ls-files --debug -s 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo ctime: 1354306311:692664264 mtime: 1354306311:692664264 dev: 28 ino: 119763 uid: 1000 gid: 1000 size: 0 flags: 0
foo
touchen, aber nicht den Inhalt verändern
$ touch foo
Keine Änderung wird erkannt & Neue m-time:
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused nothing added to commit but untracked files present (use "git add" to track)
$ git ls-files --debug -s 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo ctime: 1354306421:958755979 mtime: 1354306421:958755979 dev: 28 ino: 119763 uid: 1000 gid: 1000 size: 0 flags: 0
foo
touchen & Inhalt verändern:
$ echo "content" > foo
Änderung erkannt & m-time bleibt alt:
$ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused no changes added to commit (use "git add" and/or "git commit -a"):
$ git ls-files --debug -s 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo ctime: 1354306421:958755979 mtime: 1354306421:958755979 dev: 28 ino: 119763 uid: 1000 gid: 1000 size: 0 flags: 0
foo
In den Index hinzufügen (stagen):
$ git add foo
Änderungen übernommen (neue SHA1) & neue m-time:
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: foo # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused
$ git ls-files --debug -s 100644 d95f3ad14dee633a758d2e331151e950dd13e4ed 0 foo ctime: 1354306489:705068567 mtime: 1354306489:705068567 dev: 28 ino: 119763 uid: 1000 gid: 1000 size: 8 flags: 0
Committen:
$ git commit -a -m "Modified foo" [master fc724cf] Modified foo 1 file changed, 1 insertion(+)
Index bleibt unverändert:
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused nothing added to commit but untracked files present (use "git add" to track)
$ git ls-files --debug -s 100644 d95f3ad14dee633a758d2e331151e950dd13e4ed 0 foo ctime: 1354306489:705068567 mtime: 1354306489:705068567 dev: 28 ino: 119763 uid: 1000 gid: 1000 size: 8 flags: 0
$ cp old new
$ git rm old rm 'old'
$ git add new
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: old -> new # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # unused
$ git commit -a -m "renaming" [master 289cf21] renaming 1 file changed, 0 insertions(+), 0 deletions(-) rename old => new (100%)
Befehl | Bedeutung |
---|---|
git add -p <file> | Wähle aus welche Änderungen in den Index sollen |
git diff [<file>] | Working coppy VS. Index (of a file) |
git diff –cached [<file>] | Index VS. HEAD (of a file) |
git log [<file>] | Commit history (of a file) |
git show <ID> | Commit message + diffs |
git cat-file -p <ID> | Zeige GIT Objekte aus dem object strorre |
git clone <URL> git submodule init git submodule update | Repo mit submodulen inizialisieren (clonen) (submodule müssen extra explizit behandelt werden) |
/objects/<xx>/<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Können entweder mit
for x in t s p ; do git cat-file -$x 3d646c3d1bf84007c93ab1d78e7f6941ef65bdc2 ; done
oder mit
perl -MCompress::Zlib -e 'undef $/; print uncompress(<>)' .git/objects/28/9cf21ee611ca2c335fa77f48f4613bd5255aa3
angeschaut werden
/refs/
In Ordnern sind files die einen Hash enthalten. Somit Wird einem GIT object ein Name gegeben.
/HEAD
Referenz auf eine file in /refs
. Ist link auf den aktuellen HEAD des aktuellen branches und somit indirekt auf den letzten commit.
/refs/tags/<tag name>
<tag name> ist eine datei die den Hash eines der follgenden Objekte enthält
Was | Tag typ |
---|---|
tag object | Annotiated Tag |
blob object | Leightweight Tag |
tree object | |
commit object |