diff --git a/git-cheatsheet.typ b/git-cheatsheet.typ new file mode 100644 index 0000000..0b5e2a1 --- /dev/null +++ b/git-cheatsheet.typ @@ -0,0 +1,146 @@ +#set page( + width: 297mm, + height: 210mm, + margin:( + top: 0.5cm, + bottom: 0.5cm, + left: 0.5cm, + right: 0.5cm, + ), + columns: 2, +) +#set text(font: "Times New Roman", size: 8pt) +#set heading(numbering: "1.") +#show link: set text(fill: blue) +#show strong: set text(weight: "semibold") + +#align(center, text(14pt)[*Git Cheatsheets*]) + + +*Installation* \ +*macOS* +- 'xcode -select --install' or 'brew install git' +- Verify: 'git --version' +*Linux* +- Debian/Ubuntu: 'sudo apt install git' +- Fedora: 'sudo dnf install git' +- Arch: 'sudo pacman -S git' +- Verify: 'git --version' +*Windows* +- Download installer from [https://git-scm.com/download/win] += Quick Start +#table( + table.header([*Command*], [*Description*]), + columns: 2, + align: horizon, + inset: 6pt, + rows: auto, + [`git config --global user.name "Your Name"`],[ Set your display name for commits.], + [`git config --global user.email "you@example.com"` ],[Set your email for commits.], + [`git config --global init.defaultBranch main` ], [Use `main` for new repos.], + [`git config --global color.ui auto`],[& Enable colored CLI output. ], + [`git init [project-name]`],[ Initialize a new repo in the current directory], + [`git clone `],[Create a local copy of remote repo], + [`git remote add origin `],[Add a remote named `origin`], + [`git remote -v`], [Show remotes and their URLs.] +) + +/* +Commands for Branch & Merging section; +git banch, git branch [branch-name], git checkout, git merge []branch-name], git log +*/ + += Branch & Merge +#table( + table.header([*Command*],[*Description*]), + columns: 2, + align: horizon, + inset:6pt, + rows: auto, + [`git branch`],[List local branches.], + [`git branch `],[Create a new branch.], + [`git switch `],[Switch to an existing branch.], + [`git switch -c `],[Create and switch to a new branch.], + [`git merge `],[Merge into the current branch.], + [`git rebase `],[Replay current commits on top of .], + [`git log --oneline --graph --decorate`],[View compact commit graph.], + +) + + +#colbreak() += Inspect & Compare +#table( + table.header([*Command*],[*Description*]), + columns: 2, + align : horizon, + inset: 6pt, + rows: auto, + [`git log`],[Show the commit history for the currently active branch.], + [`git log branchB..branchA`],[Show the commits on branchA that are not on branchB.], + [`git log --follow [file]`],[Show the commits that changed file, even across renames.], + [`git diff branchB...branchA`],[Show the diff of what is in branchA that is not in branchB.], + [`git show [SHA]`],[Show any object in Git in human-readable format.], +) + + += Share & Update +#table( + table.header([*Command*],[*Description*]), + columns: 2, + inset:6pt, + rows: auto, + align: horizon, + [`git fetch`],[Download updates from remote (no integrate).], + [`git pull`],[Fetch and integrate into current branch.], + [`git push`],[Upload local commits to remote.], + [`git push -u origin `],[Push and set upstream for .], + [`git fetch --prune`],[Remove refs deleted on remote.], +) + += Rewriting Git History +#table( + table.header([*Command*],[*Description*]), + columns: 2, + align: horizon, + inset:6pt, + rows: auto, + [`git commit --amend`],[Edit the last commit message or content.], + [`git rebase -i `],[Interactively rebase commits onto .], + [`git reset --soft `],[Move HEAD, keep changes staged.], + [`git reset --hard `],[Move HEAD, discard all changes.], + [`git revert `],[Create a new commit that undoes .], + +) + += Temporary Commits: storing your temp work +#table( + table.header([*Command*],[*Description*]), + columns: 2, + align: horizon, + inset:6pt, + rows: auto, + [`git stash`],[Save changes for later, keep working directory clean.], + [`git stash pop`],[Re-apply the most recent stash and remove it.], + [`git stash list`],[Show all stashed changes.], + [`git stash drop`],[Delete a stash entry.], +) + +#colbreak() +// tagging commits + = Tagging Commits +#table( + table.header([*Command*],[*Description*]), + columns: 2, + inset: 6pt, + align: horizon, + rows: auto, + [`git tag`],[List all tags in the repository.], + [`git tag [name] [commit sha]`],[Create a new tag at the specified commit (or HEAD if omitted).], + [`git tag -d [name]`],[Delete a local tag.], + [`git push origin [name]`],[Push a specific tag to the remote repository.], + [`git push origin --tags`],[Push all local tags to the remote repository.], +) + + +