;#; [[developer_resources|Back to Developers Page]] ;#; Source: http://jonas.nitro.dk/git/quick-reference.html a) Getting help: * Show help for a command * git help command OR git command --help b) Repository creation: * Create a repository in the current directory * git init * Clone a remote repository into a subdirectory * git clone url c) File operations: * Add file or files in directory recursively * git add path * Remove file or directory from the working tree * git rm path * -f : Force deletion of file(s) from disk * Move file or directory to new location * git mv path destination * -f : Overwrite existing destination files * Restore file from current branch or revision * git checkout [rev] file * -f : Overwrite uncommitted local changes d) Working tree: * Show status of the working tree * git status * Show diff of changes in the working tree * git diff [path] * Show diff of stages and unstaged changes * git diff HEAD path * Stage file for commit * git add path * Unstage file for commit * git reset HEAD path * Commit files that has been staged (with git-add) * git commit * -a : Automatically stage all modified files * Undo commit & keep changes in the working tree * git reset --soft HEAD^ * Reset the working tree to the last commit * git reset --hard HEAD^ * Clean unknown files from the working tree * git clean * Record the current state of the working directory and clean it * git stash e) Examining History: * View commit log, optionally for specific path * git log [path] * View commit log for a given revision range * git log [from[..to]] * --stat : List diffstat for each revision * -S'pattern' : Search history for changes matching pattern * Show file annotated with line modifications * git blame [file] f) Remote repositories - remotes: * Fetch changes from a remote repository * git fetch [remote] * Fetch and merge changes from a remote repository * git pull [remote] * Push changes to a remote repository * git push [remote] * List remote repositories * git remote * Add remote to list of tracked repositories * git remote add remote url g) Branches: * Switch working tree to branch * git checkout branch * -b branch : Create branch before switching to it * List local branches * git branch * Overwrite existing branch, start from revision * git branch -f branch rev * Merge changes from branch * git merge branch h) Exporting and importing: * Apply patch from stdin * git apply - < file * Format a patch with log message and diffstat * git format-patch from[..to] * Export snapshot of revision to file * git archive rev > file * --prefix=dir/ : Nest all files in the snapshot in directory * --format=[tar|zip] : Specify archive format to use: tar or zip i) Tags: * Create tag for a given revision * git tag name [revision] * -s : Sign tag with your private key using GPG * -l [pattern] : List tags, optionally matching pattern j) File status flags: * M (modified) : File has been modified * C (copy-edit) : File has been copied and modified * R (rename-edit) : File has been renamed and modified * A (added) : File has been added * D (deleted) : File has been deleted * U (unmerged) : File has conflicts after a merge ;#; [[developer_resources|Back to Developers Page]] ;#;