📎 Webclip
8 Small git tips
The post gathers eight short Git tips the author uses almost every day. It focuses on ways to stage only part of a file, reorganize commit history, keep temporary changes out of the way, reduce noise from local generated files, and inspect history more clearly.
Reading notes#
git add -plets you interactively choose which chunks of a file go into a commit, andgit checkout -pdoes the same for changes you want to revert.git diff --cachedshows what has been selected after partial staging.git rebase -i <commit>lets you pick, squash, reword, edit, or remove commits, but it changes history and should not be used on shared or already pushed branches.git stashstores work in progress when you need to switch contexts, and the author prefers to keep the stash empty by checking it withgit stash show -p, then popping or clearing it.- A global ignore file can be configured with
git config --global core.excludesfile=/Users/flores/.gitignorefor files generated locally, such as editor backup files or.DS_Store. apply.whitespace=warnmakes Git warn about trailing whitespace when staging chunks withgit add -p.branch.autosetuprebase=alwaysmakes pulls try to reapply local commits instead of creating a merge commit.git log --graph --decorate --pretty=oneline --abbrev-commitgives a more useful view of branch history and commit points.git commit --amendrewrites the last commit message and can include newly staged changes, but it also changes history and may require a force push.
