Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 2.14 KB

File metadata and controls

85 lines (63 loc) · 2.14 KB

Git Knowledge

Questions

Have you used Git before?
Yes I've used git in projects for version control and collaboration.

Which Git client did you choose? Why?
Git CLI + Zed's inbuilt git viewer. git log --graph --all --oneline

Most interesting thing learned today?
git rerere (Reuse Recorded Resolution) Git remembers how you resolved a merge conflict and reapplies it automatically next time.

git config --global rerere.enabled true

Core Knowledge

Clean branch history

# First conflict on branch-a
git rebase main        # conflict in auth.js -> resolve manually

Init & Basic Workflow

git init                          # initialise repo
git add .                         # stage all changes
git commit -m "message"           # commit staged changes
git commit --amend -m "new msg"   # edit last commit message

Remotes

# HTTPS (simpler, less secure)
git remote add origin https://github.com/eyeofastarte/repo.git

# SSH (preferred more secure, no password prompts)
git remote add origin eyeofastarte@host:path/repo.git

Push / Pull / Fetch

git push          # upload local commits to remote
git pull          # fetch + merge remote changes
git fetch         # download remote changes without merging

Branches

git branch -a                   # list all branches (local + remote)
git checkout -b <branch>        # create and switch to new branch
                                # avoids Detached HEAD state

Rebase

git rebase <branch>    # replay current branch commits on top of <branch>
git rebase --abort     # cancel an in-progress rebase

Commit Types

Type Use
feat New feature for the user
fix Bug fix for the user
docs Documentation changes only
style Formatting, missing semicolons
refactor Code restructure
perf Performance improvements
test Adding or refactoring tests
chore Dependency updates, build tools
build Changes to build system or external dependencies
ci Configuration or scripts
revert Reverting a previous commit