computing:git
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computing:git [2026/04/26 10:13] – oscar | computing:git [2026/10/01 10:42] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== GIT ====== | ||
| - | ---- | ||
| - | ==== Getting Started ==== | ||
| - | ^Task^Command^ | ||
| - | |Start a new repo|git init| | ||
| - | |Clone an existing repo|git clone < | ||
| - | ==== Configure Git ==== | ||
| - | ^Task^Command^ | ||
| - | |Set a config option |git config user.name 'Your Name'| | ||
| - | |Set a config option |git config user.email 'Your email' | ||
| - | |Set option globally |git config --global ... | | ||
| - | |Add an alias|git config alias.st status| | ||
| - | |See all possible config options| man git-config| | ||
| - | |||
| - | ==== Prepare to Commit ==== | ||
| - | ^Task^Command^ | ||
| - | |Add untracked file or unstaged changes|git add < | ||
| - | |Add all untracked files and unstaged changes|git add .| | ||
| - | |Choose which parts of a file to stage |git add -p| | ||
| - | |Move file|git mv <old> < | ||
| - | |Delete file|git rm < | ||
| - | |Tell Git to forget about a file without deleting it|git rm --cached < | ||
| - | |Unstage one file|git reset < | ||
| - | |Unstage everything|git reset| | ||
| - | |Check what you added|git status| | ||
| - | |||
| - | ==== Make Commits ==== | ||
| - | ^Task^Command^ | ||
| - | |Make a commit (and open text editor to write message)|git commit| | ||
| - | |Make a commit|git commit -m ' | ||
| - | |Commit all unstaged changes|git commit -am ' | ||
| - | |||
| - | ==== Move Between Branches ==== | ||
| - | ^Task^Command^ | ||
| - | |Switch branches|git switch < | ||
| - | |Create a branch|git switch -c < | ||
| - | |List branches|git branch| | ||
| - | |List branches by most recently committed to|git branch --sort=-committerdate| | ||
| - | |Delete a branch|git branch -d < | ||
| - | |Force delete a branch|git branch -D < | ||
| - | |||
| - | ==== Diff Staged/ | ||
| - | ^Task^Command^ | ||
| - | |Diff all staged and unstaged changes|git diff HEAD| | ||
| - | |Diff just staged changes|git diff --staged| | ||
| - | |Diff just unstaged changes|git diff| | ||
| - | |||
| - | ==== Diff Commits ==== | ||
| - | ^Task^Command^ | ||
| - | |Show diff between a commit and its parent|git show < | ||
| - | |Diff two commits|git diff < | ||
| - | |Diff one file since a commit|git diff < | ||
| - | |Show a summary of a diff|git diff < | ||
| - | |||
| - | ==== Discard Your Changes ==== | ||
| - | ^Task^Command^ | ||
| - | |Delete unstaged changes to one file|git restore < | ||
| - | |Delete all staged and unstaged changes to one file| git restore --staged --worktree < | ||
| - | |Delete all staged and unstaged changes|git reset --hard| | ||
| - | |Delete untracked files|git clean| | ||
| - | |' | ||
| - | |||
| - | ==== Edit History ==== | ||
| - | ^Task^Command^ | ||
| - | |" | ||
| - | |Squash the last 5 commits into one|git rebase -i HEAD~6 \\ Then change " | ||
| - | |Undo a failed rebase|git reflog BRANCHNAME \\ Then manually find the right commit ID in the reflog, then run: \\ git reset --hard < | ||
| - | |Change a commit message (or add a file you forgot)|git commit --amend| | ||
| - | |||
| - | |||
| - | ==== Important Files ==== | ||
| - | ^Task^Command^ | ||
| - | |Local git config|.git/ | ||
| - | |Global git config|~/ | ||
| - | |List of files to ignore|.gitignore| | ||
| - | |||
| - | ==== Links ==== | ||
| - | * [[https:// | ||
computing/git.1777198404.txt.gz · Last modified: by oscar
