git update
The daily git workflow: check the status, fetch, switch branches, commit and push
· by Aron Kovacs
1. what is a git update workflow?
A git update workflow is the complete process of syncing your local repository with the remote, making changes, and pushing them back. This is the daily bread and butter of version control.
2. checking status
Always start by checking what's changed:
git status # see what's modified
This shows modified files, untracked files, and your current branch.
3. fetching latest changes
Fetch updates from remote without merging:
git fetch origin # download updates
This downloads new data but doesn't modify your working directory.
4. switching branches
Switch to a different branch:
git checkout branch-name
Create and switch to a new branch:
git checkout -b new-branch-name # creates & switches
Modern syntax (Git 2.23+):
git switch branch-name
git switch -c new-branch-name # creates & switches
5. pulling changes
Pull and merge changes from remote branch:
git pull origin branch-name # fetch + merge
This is essentially a fetch + merge. It updates your current branch with remote changes.
6. staging changes
Add specific file to staging:
git add filename.ext
Add all changes:
git add . # stages everything
Add all files of a certain type:
git add *.ts # all TypeScript files
Interactive staging (choose what to add):
git add -p # pick changes interactively
7. committing changes
Commit staged changes with a message:
git commit -m "Your descriptive commit message"
Commit all modified files (skip staging):
git commit -am "Your message" # adds & commits
Write clear, descriptive commit messages. Good format: "verb + what changed" like "Add login feature" or "Fix navigation bug".
8. pushing changes
Push to remote branch:
git push origin branch-name
Push and set upstream (first time pushing a new branch):
git push -u origin branch-name # sets upstream
After setting upstream, you can just use:
git push # uses saved upstream
9. complete workflow example
Here's a typical update workflow:
git status
git fetch origin
git checkout develop
git pull origin develop
git add .
git commit -m "Update skill tree styling"
git push origin develop
10. checking remote information
View remote repository URLs:
git remote -v
View all branches (local and remote):
git branch -a
11. common issues and solutions
Merge conflicts: When pulling, if there are conflicts:
git status
Edit conflicting files, then:
git add .
git commit -m "Resolve merge conflicts"
Uncommitted changes when switching branches:
git stash
git checkout other-branch
git stash pop
Pushed wrong commit:
git revert commit-hash
git push origin branch-name
Pro tip: Never use git push --force on shared branches like main or develop unless you absolutely know what you're doing and have team approval. It can overwrite others' work.
12. viewing commit history
View detailed commit log:
git log
Compact one-line view:
git log --oneline
View commits with file changes:
git log --stat
View visual branch graph:
git log --graph --oneline --all