Git commands one more time

This is actually based and mostly copied from great article of Eli Schleifer, read all here: https://blog.trunk.io/minimum-viable-git-for-trunk-based-development-81a5da7a77a7

Branch Management

git checkout -t -b {branch-name} 
Make a branch, set the upstream to the current branch, and switch to it. You can also do this via the `git branch` command, but it takes multiple commands. Since I always want to switch to a branch when I create it, this command is more succinct. Create and checkout the branch in one fell swoop. I usually name all my branches yourname/{work-being-done}.

git checkout {branch-name}
Switch to a branch.

git branch -vv
View your current branches and their upstreams.

git branch -D {branch-name}
Delete a local branch, usually to clean up stale/merged-into-main branches.

Pushing & Pulling

git fetch origin main:main
Pull the remote main into your local main, even when you’re not currently on the main branch! That’s the key; very useful when you’re trying to merge the latest main into a PR branch.

git push origin
Push my code to the remote; likely spinning up lots of machines in CI to check my work.

git pull
Update my local branch with the remote of the same name.

Committing

git add -A .
Add everything I’m working on (new and edited files).

git commit -am "work"
See here for a deep dive into my thoughts on local commit messages

git merge main
Lots more on this below. I am pragmatic and not a rebaser and happy to muddy my local branch with the goings-on from main.

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *