git_reference
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| git_reference [2017/02/03 03:08] – created maefloresta | git_reference [2017/03/11 23:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| * Create a repository in the current directory | * Create a repository in the current directory | ||
| * git init | * git init | ||
| + | |||
| * Clone a remote repository into a subdirectory | * Clone a remote repository into a subdirectory | ||
| * git clone url | * git clone url | ||
| Line 21: | Line 22: | ||
| * Add file or files in directory recursively | * Add file or files in directory recursively | ||
| * git add path | * git add path | ||
| + | |||
| * Remove file or directory from the working tree | * Remove file or directory from the working tree | ||
| * git rm path | * git rm path | ||
| * -f : Force deletion of file(s) from disk | * -f : Force deletion of file(s) from disk | ||
| - | 6. git mv path destination | + | * Move file or directory to new location |
| + | * git mv path destination | ||
| + | * -f : Overwrite existing destination files | ||
| - | | + | |
| - | + | | |
| - | | + | |
| - | + | ||
| - | 7. git checkout [rev] file | + | |
| - | + | ||
| - | Restore file from current branch or revision | + | |
| - | + | ||
| - | | + | |
| d) Working tree: | d) Working tree: | ||
| - | 8. git status | + | * Show status of the working tree |
| + | * git status | ||
| - | Show status | + | |
| + | * git diff [path] | ||
| - | 9. git diff [path] | + | * Show diff of stages and unstaged changes |
| + | * git diff HEAD path | ||
| - | | + | |
| + | * git add path | ||
| - | 10. git diff HEAD path | + | * Unstage file for commit |
| + | * git reset HEAD path | ||
| - | | + | |
| + | * git commit | ||
| + | * -a : Automatically stage all modified files | ||
| - | 11. git add path | + | * Undo commit & keep changes in the working tree |
| + | * git reset --soft HEAD^ | ||
| - | | + | |
| + | * git reset --hard HEAD^ | ||
| - | 12. git reset HEAD path | + | * Clean unknown files from the working tree |
| + | * git clean | ||
| - | | + | |
| - | + | * git stash | |
| - | 13. git commit | + | |
| - | + | ||
| - | Commit files that has been staged (with git-add) | + | |
| - | + | ||
| - | -a : Automatically stage all modified files | + | |
| - | + | ||
| - | 14. git reset --soft HEAD^ | + | |
| - | + | ||
| - | Undo commit & keep changes in the working tree | + | |
| - | + | ||
| - | 15. git reset --hard HEAD^ | + | |
| - | + | ||
| - | Reset the working tree to the last commit | + | |
| - | + | ||
| - | 16. git clean | + | |
| - | + | ||
| - | Clean unknown files from the working tree | + | |
| - | + | ||
| - | 17. git stash | + | |
| - | + | ||
| - | | + | |
| e) Examining History: | e) Examining History: | ||
| - | 18. git log [path] | + | * View commit log, optionally for specific path |
| - | + | | |
| - | | + | |
| - | + | ||
| - | 19. git log [from[..to]] | + | |
| - | + | ||
| - | View commit log for a given revision range | + | |
| - | + | ||
| - | --stat : List diffstat for each revision | + | |
| - | + | ||
| - | -S' | + | |
| - | 20. git blame [file] | + | * View commit log for a given revision range |
| + | * git log [from[..to]] | ||
| + | * --stat : List diffstat for each revision | ||
| + | * -S' | ||
| - | Show file annotated with line modifications | + | |
| + | * git blame [file] | ||
| f) Remote repositories - remotes: | f) Remote repositories - remotes: | ||
| - | 21. git fetch [remote] | + | * Fetch changes from a remote repository |
| + | * git fetch [remote] | ||
| - | Fetch changes from a remote repository | + | |
| + | * git pull [remote] | ||
| - | 22. git pull [remote] | + | * Push changes to a remote repository |
| + | * git push [remote] | ||
| - | | + | |
| + | * git remote | ||
| - | 23. git push [remote] | + | * Add remote to list of tracked |
| - | + | | |
| - | Push changes | + | |
| - | + | ||
| - | 24. git remote | + | |
| - | + | ||
| - | List remote | + | |
| - | + | ||
| - | 25. git remote add remote url | + | |
| - | + | ||
| - | Add remote to list of tracked repositories | + | |
| g) Branches: | g) Branches: | ||
| - | 26. git checkout branch | + | * Switch working tree to branch |
| + | * git checkout branch | ||
| + | * -b branch : Create branch before switching to it | ||
| - | | + | |
| + | * git branch | ||
| - | -b branch | + | * Overwrite existing |
| + | * git branch -f branch | ||
| - | 27. git branch | + | * Merge changes from branch |
| - | + | | |
| - | List local branches | + | |
| - | + | ||
| - | 28. git branch -f branch rev | + | |
| - | + | ||
| - | Overwrite existing branch, start from revision | + | |
| - | + | ||
| - | 29. git merge branch | + | |
| - | + | ||
| - | Merge changes from branch | + | |
| h) Exporting and importing: | h) Exporting and importing: | ||
| - | 30. git apply - < file | + | * Apply patch from stdin |
| + | * git apply - < file | ||
| - | | + | |
| + | * git format-patch from[..to] | ||
| - | 31. git format-patch from[..to] | + | * Export snapshot of revision |
| - | + | | |
| - | Format a patch with log message and diffstat | + | |
| - | + | | |
| - | 32. git archive rev > file | + | |
| - | + | ||
| - | Export snapshot of revision to file | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| i) Tags: | i) Tags: | ||
| - | 33. git tag name [revision] | + | * Create tag for a given revision |
| - | + | * git tag name [revision] | |
| - | | + | |
| - | + | | |
| - | -s : Sign tag with your private key using GPG | + | |
| - | + | ||
| - | | + | |
| j) File status flags: | j) File status flags: | ||
| - | M (modified) : File has been modified | + | * 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]] | [[developer_resources|Back to Developers Page]] | ||
| ;#; | ;#; | ||
git_reference.1486091289.txt.gz · Last modified: 2017/03/11 23:22 (external edit)
