Git commands: practical guide for developers
Tips 'n tricks about the web, digital trends, and online marketing
Git commands, the backbone of modern software development
At Funkhaus, we build websites, web apps and smart marketing flows every day. In these, we rely on Git to securely record our work, collaborate smoothly and revert to a previous version without risk when needed.
In this knowledge base article, we will take you through what exactly Git is, what you use it for and why it is so important in the way we work. Then we share a comprehensive list of useful Git commands, including examples and tips that we apply ourselves in our projects.
What is Git?
Git is a distributed version control system: each developer has local access to the complete code history. This makes operations such as commits, diff and branch management extremely fast and reliable. Instead of one central source, you keep local snapshots (commits) that you can later push to a remote such as GitHub, GitLab or Bitbucket. For a full reference, check out Git's official documentation and the free book Pro Git.
Why do you use Git and why is it important?
Git makes collaboration predictable: multiple people can work simultaneously on features in separate branches without overwriting each other's work. Each commit contains who changed something and why, which is important for traceability and debugging. Git supports workflows with code reviews, CI/CD pipelines and rollback capabilities, so errors are quickly detected and fixed. Integration with tools like GitHub Actions and GitLab CI helps automate quality during every push. For example, see the GitHub Actions documentation for examples of CI workflows: https://docs.github.com/actions
Core concepts in one sentence
- Repository: the project folder containing the .git directory
- Commit: a snapshot of your code including metadata
- Branch: a reference to a set of commits
- Remote: an external repository (e.g. origin)
- Staging area (index): intermediate layer between working tree and commit
Useful git commands and what they do
Below you will find an elaborated list of commands that are most useful in practice. For each command, I explain what it does, when to use it and give an example.
git init
Initialises a new Git repository in the current folder. Use this if you want to start a project locally with version control.
Tip: Immediately add a .gitignore with files that should not be under version control (build-artifacts, credentials, node_modules).
git clone
Creates a local copy of a remote repository. Retrieves the full history.
git clone https://github.com/organisatie/project.git
Tip: Use -depth for a shallow clone if you only need the latest history.
git status
Shows which files have been modified, which are staged and which are unstaged. This is often the first command you run.
git add
Place changes in the staging area so that they become part of the next commit. You can add individual files or everything.
git add index.html
git add -A # all changes
Tip: Use small, logical commits by adding and committing related changes each time.
git commit
Create a snapshot of steady changes. Write clear commit messages.
git commit -m "fix: responsive header and accessibility improvements"
Tip: Use conventions such as Conventional Commits for consistent messages: https://www.conventionalcommits.org
git log
Shows the commit history. Useful flags: -oneline -graph -decorate -all for a compact view.
git log -oneline -graph -decorate -all
git diff
Compare changes between working tree, index and commits.
git diff # unstaged changes
git diff -staged # staged changes
git diff HEAD~1..HEAD
Tip: Use this to check what you are going to commit.
git show
Displays the content and metadata of a specific commit or ref.
git show 7f3a2b1
git branch
Shows or makes branches. -a also shows remotes.
git branch # list local
git branch -a # list including remote branches
git branch feature/search
git switch / git checkout
git switch is the more modern way to switch between branches (git checkout is also possible).
git switch feature/search function
git switch -c feature/new
git merge
Merge another branch into your current branch. You can get a fast-forward or a merge commit.
git switch main
git merge feature/search
Tip: Always check tests after a merge and resolve conflicts.
git rebase
Move your commits on a new base; this gives a linear history. Use rebase locally and before you push to remote to keep history clean.
git switch feature/search function
git rebase main
Note: rebase rewrites history - don't do this on shared branches without consultation.
Read more about merge vs rebase: https://www.atlassian.com/git/tutorials/merging-vs-rebasing
git fetch / git pull / git push
fetch retrieves refs without merging. pull is fetch + merge (or -rebase). push pushes your commits to remote.
git fetch origin
git pull -rebase origin main
git push origin feature/search
Tip: Use git pull -rebase if you want a neat history.
git stash
Save temporary, uncommitted changes and clean up your working tree. Useful if you need to change context quickly.
git stash
git stash list
git stash doll
git restore
Recover files from commit or delete them from the staging area. This is the more modern replacement for certain checkout operations.
git restore README.md # restores working tree
git restore -staged README.md # removes from staging
git reset
Move HEAD and possibly index/working tree. -soft, -mixed, -hard have different impact. Use with caution.
git reset -soft HEAD~1
git reset -hard HEAD~1 # destructive
git cherry-pick
Transfer a specific commit to your current branch. Useful for hotfixes.
git cherry-pick 3a4b5c6
git clean
Delete unversioned files. Note: irreversible without backup.
git clean -fd
git mv / git rm
Move or delete files while preserving history.
git mv oldName.php newName.php
git rm unwanted.txt
Best practices and workflows
- Make small, logical commits with clear messages. Describe the why, not just the what.
- Keep sensitive data never in the repo; use environment variables and secrets in your CI platform.
- Choose a branching strategy that suits your team: GitHub Flow is simple for continuous deploys; GitLab Flow helps with multiple environments. See workflows: https://www.atlassian.com/git/tutorials/comparing-workflows
- Use git rebase locally to keep your feature branch up-to-date, but use git revert on shared branches to safely roll back changes.
Concluding remarks and sources
With these commands and explanations, you'll have a solid foundation for working efficiently with Git. Git offers a lot of depth - from simple commits to advanced rebase and bisect workflows - but by understanding the core concepts and practising the above commands, you quickly become more productive.
Recommended reading tips and references:
- Official Git documentation: https://git-scm.com/docs
- Pro Git (free online book): https://git-scm.com/book/en/v2
- Merging vs rebase (Atlassian): https://www.atlassian.com/git/tutorials/merging-vs-rebasing
- GitHub Actions (CI/CD): https://docs.github.com/actions
- GitLab CI/CD: https://docs.gitlab.com/ee/ci/
👉 Funkhaus goes the extra mile for you
We are the all-in-one partner that takes care of everything: from creative web designs to technical optimisations and strategic content. You focus on your business, we take care of the rest.
Send us an email for personal advice
Get in touch, and we'll schedule an appointment soon
👋 Hi, we are there for you!
What our partners say
wommel94 wommelgem
Quality services that help us find new customers and retain existing ones. Pleasant and efficient cooperation.
Nick Van der Hallen
Fantastic and honest company with very flexible and fast customer service. Funkhaus took our new website to the next level, with plenty of options to expand on later. Great to work with and highly recommended!
Koen Van den Abeele
Top service!
Highly recommended to anyone looking for reliable & honest marketing support with a creative touch!👌
Yv. Private
Always a very quick response and strong in communication. Wout can switch quickly and always understands immediately what I mean. The end result is therefore always quick and immediately satisfactory. Definitely highly recommended!
WIS WIS
Fast and strong service.
Customer-tailored advice.
Peter Claes
I contacted Wout as part of a mini RFP where he came out on top in a selection of 13 competitors. He was not the cheapest but stood head and shoulders above the competition in terms of responsiveness, clarity, transparency, helpfulness and willingness to listen.
From the start of my project, it turned out to be precisely these qualities that ensured that every question, every suggestion and the countless times I changed my mind were calmly and openly met and resolved by Wout.
Each time, he managed to clarify my sometimes confused suggestions, offer some solutions and then, above all, implement them at lightning speed (even "on the spot" in some cases).
His communication is calm, friendly, never pedantic or unnecessarily complicated. He is approachable, always accessible and keeps his appointments.
He will also explain his views on certain decisions and frame them with the necessary diplomacy.
He kept me informed at every step of the progress he had made, the next steps and the actions I still needed to take myself.
And the result is a website that runs flawlessly and that I can be incredibly proud of. NPS 10/10.
Saar
The entire Eurowaste team would like to thank your team at Funkhaus for the smooth and professional cooperation. We currently have a fresh new website that works well. Thanks also for getting our 'socials' like LinkedIn in order.
karine peeters
Great performance by wout. Received a lot of good comments from my customers regarding the website. The professional approach, the class that the website exudes and the top service before, during and after the launch of the website is outstanding. For a beautiful professional website 1 address. @funkhaus 👌
Emmanuel Verraes
Very hands-on and service-minded! I have been recommended Funkhaus by another customer and I - on turn - highly recommend their services.
P DB
What a pleasant collaboration with Wout and his team. Funkhaus built 2 excellent websites and is working on the digital marketing for my company. Professional, always correct, very knowledgeable and super helpful.