User Tools

Site Tools


git_reference

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

git_reference [2017/02/02 22:08]
maefloresta created
git_reference [2017/02/02 22:55]
maefloresta
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
  
-    ​Move file or directory to new location +    ​* Restore ​file from current branch ​or revision 
- +      ​git checkout [rev] file 
-      ​-f : Overwrite existing destination files +        ​* ​-f : Overwrite uncommitted local changes
- +
-7. git checkout [rev] file +
- +
-    Restore file from current branch or revision +
- +
-      ​-f : Overwrite uncommitted local changes+
  
 d) Working tree: d) Working tree:
  
-8. git status+    * Show status of the working tree 
 +      * git status
  
-    Show status ​of the working tree+    ​Show diff of changes in the working tree 
 +      * git diff [path]
  
-9. git diff [path]+    * Show diff of stages and unstaged changes 
 +      * git diff HEAD path
  
-    ​Show diff of changes in the working tree+    ​* Stage file for commit 
 +      * git add path
  
-10. git diff HEAD path+    * Unstage file for commit 
 +      * git reset HEAD path
  
-    ​Show diff of stages and unstaged changes+    ​* Commit files that has been staged (with git-add) 
 +      * git commit 
 +        * -a : Automatically stage all modified files
  
-11. git add path+    * Undo commit & keep changes in the working tree 
 +      * git reset --soft HEAD^
  
-    ​Stage file for commit+    ​* Reset the working tree to the last commit 
 +      * git reset --hard HEAD^
  
-12. git reset HEAD path+    * Clean unknown files from the working tree 
 +      * git clean
  
-    ​Unstage file for commit +    ​Record the current state of the working directory and clean it 
- +      * 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 +
- +
-    ​Record the current state of the working directory and clean it+
  
 e) Examining History: e) Examining History:
  
-18. git log [path] +    * View commit log, optionally for specific path 
- +      ​* ​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'​pattern'​ : Search history for changes matching pattern+
  
-20. git blame [file]+    * 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+    ​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+    ​Fetch and merge changes from a remote repository 
 +      * git pull [remote]
  
-22. git pull [remote]+    * Push changes to a remote repository 
 +      * git push [remote]
  
-    ​Fetch and merge changes from a remote ​repository+    ​* List remote repositories 
 +      * git remote
  
-23. git push [remote+    * Add remote to list of tracked ​repositories 
- +      ​* ​git remote add remote url
-    Push changes ​to a remote repository +
- +
-24. git remote +
- +
-    List remote ​repositories +
- +
-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
  
-    ​Switch working tree to branch+    ​* List local branches 
 +      * git branch
  
-      -b branch ​: Create ​branch ​before switching to it+    * Overwrite existing ​branch, start from revision 
 +      * git branch -f branch ​rev
  
-27. git branch +    * Merge changes from branch 
- +      ​* ​git merge 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
  
-    ​Apply patch from stdin+    ​* Format a patch with log message and diffstat 
 +      * git format-patch from[..to]
  
-31. git format-patch from[..to] +    * Export snapshot of revision ​to file 
- +      ​* ​git archive rev > file 
-    Format a patch with log message and diffstat +        ​* ​--prefix=dir/​ : Nest all files in the snapshot in directory 
- +        ​* ​--format=[tar|zip] : Specify archive format to use: tar or zip
-32. git archive rev > file +
- +
-    Export snapshot of revision to file +
- +
-      ​--prefix=dir/​ : Nest all files in the snapshot in directory +
- +
-      ​--format=[tar|zip] : Specify archive format to use: tar or zip+
  
 i) Tags: i) Tags:
  
-33. git tag name [revision] +    * Create tag for a given revision 
- +      * git tag name [revision] 
-    ​Create tag for a given revision +        ​* ​-s : Sign tag with your private key using GPG 
- +        ​* ​-l [pattern] : List tags, optionally matching pattern
-      -s : Sign tag with your private key using GPG +
- +
-      ​-l [pattern] : List tags, optionally matching pattern+
  
 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 
-C (copy-edit) : File has been copied and modified +    ​* ​R (rename-edit) : File has been renamed and modified 
- +    ​* ​A (added) : File has been added 
-R (rename-edit) : File has been renamed and modified +    ​* ​D (deleted) : File has been deleted 
- +    ​* ​U (unmerged) : File has conflicts after a merge
-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.txt · Last modified: 2019/07/16 20:31 (external edit)