Getting started
Everyday git commands
The git commands used most often, day to day. Run them inside the repo folder.
Checking the state
git status # which files changed
git diff # changes not yet added
git log --oneline -10 # last 10 commits
git branch -a # all local & remote branches
Saving changes (commit)
git add file.rb # choose files for the commit
git add . # or all changes
git commit -m "Explain what & why"
A good commit message: a short first line (≤ 72 characters), details below if needed. Write Closes #12 to close issue #12 when the commit reaches the main branch.
Syncing with Lumbung
git pull # fetch & merge the latest changes
git push # send your commits
git fetch # fetch without merging
Branches
git switch -c feature/login # create & switch to a new branch
git switch main # back to main
git push -u origin feature/login # push the new branch (-u once)
git branch -d feature/login # delete a merged local branch
Undoing
git restore file.rb # discard changes not yet added
git restore --staged file.rb # undo git add
git commit --amend # change the last commit (not pushed yet!)
git revert <sha> # make a commit that undoes an old one
git stash # stash changes temporarily
git stash pop # bring them back
Avoid
git push --forceon shared branches. Lumbung's protected branches reject it.
Files git should ignore
Create a .gitignore in the repo root — the empty-repo page has a .gitignore button with templates for Rails, Node, Python, Go, Flutter, and Laravel. Never commit passwords, .env files, or private keys.