Git โ€” Daily Workflow and Command Reference

Aug 8, 2026 11:25am · 52 views
notereference1c3d
Markdown

Git โ€” Daily Workflow and Command Reference

Daily Workflow

git status                    # check what changed
git add .                     # stage all changes
git add path/to/file          # stage specific file
git commit -m "message"       # commit
git push                      # push to remote
git pull                      # pull from remote

Branching

git branch                    # list branches
git checkout -b feature-name  # create and switch
git checkout main             # switch to main
git merge feature-name        # merge branch
git branch -d feature-name    # delete branch (merged)
git branch -D feature-name    # force delete

Viewing History

git log --oneline             # compact log
git log --oneline --graph     # with branch graph
git diff                      # unstaged changes
git diff --staged             # staged changes
git show abc1234              # show specific commit

Undoing

git restore file.php          # discard unstaged changes
git restore --staged file.php # unstage file
git reset HEAD~1              # undo last commit (keep changes)
git reset --hard HEAD~1       # undo last commit (discard changes)
git revert abc1234            # reverse a commit (safe for shared)

Remote

git remote -v                 # list remotes
git remote add origin [url]   # add remote
git fetch origin              # fetch (don't merge)
git push -u origin main       # set upstream and push
git clone [url]               # clone repo

Stash

git stash                     # stash changes
git stash pop                 # restore stash
git stash list                # list stashes
git stash drop                # discard top stash

Config

git config --global user.name "Jamey"
git config --global user.email "[email protected]"
git config --global core.editor "nano"
git config --list