meta data for this page
  •  

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:tools:git [2026/06/10 12:33] titannetlinux:tools:git [2026/06/10 12:54] (current) titannet
Line 1: Line 1:
 ====== Git ====== ====== Git ======
 +[[https://git-scm.com/cheat-sheet]]
  
 ===== Workflow ===== ===== Workflow =====
  
  
-| git init . | | +''git config --global user.name ""'', ''git config user.name "Project Name"''| | 
-| git branch <name>, git checkout <name> | create branch, switch branch +| ''git config --global user.email "you@example.com"'' | | 
-| git add -| | +| ''git init .'', ''git clone <url>'' Initialize git in current folder or clone from url
-| git commit -am 'message' | | +''git remote add <remote>'' | |  
-| git pull [origin] [branch] | | +| ''git add -A''''git add .'', ''git add <file>'' | | 
-| git push <origin> <branch> | |+''git reset <>'' | unstage, opposite of add 
 +| ''git commit -m 'message''' commit staged changes 
 +''git commit -am 'message''' | commit all unstaged changes 
 +''git pull [origin] [branch]'' | | 
 +''git push <origin> <branch>'' | |
 | | | | | |
  
 +<file bash .gitignore>
 +file_to_ignore
 +folder_to_ignore/
 +
 +*.tmp      
 +my?ile.txt
 +log[0-9].txt
 +!important.tmp #negate
 +
 +</file>
 +
 +
 +| ''git reset --hard'' | Remove staged and unstaged changes |
 +| ''git reset HEAD^'' | Undo most recent commit |
 +| ''git reset --hard <commit>'' | Go back to specific commit |
 +| ''git clean'' | Delete untracked files (temporary files and leftovers)|
 +
 +| ''git diff'' | Show difference between current and head |
 +| ''git diff HEAD'' | Diff staged and unstaged changes |
 +| ''git diff --staged'' | Diff staged changes |
 +| ''git restore <file>'' | Delete unstaged changes to one file | 
 +
 +
 +
 +==== Branch and merge ====
 +
 +| ''git checkout -b <name>'' | create branch |
 +| ''git checkout <name>'' | switch branch |
 +| ''git branch'' | list branches |
 +| ''git merge <name>'' | merge current branch with <name> |
 +| ''git mergetool'' | run merge tool to fix merge errors |
 +| ''git branch -d <name>'', ''-D'' | delete / force delete branch |
 +| ''git config --global merge.tool p4merge'' | Define merge tool |