1. git diff
: See What’s Changed
git diff
shows you the difference between various states of your code. This can be between your working directory and the staging area, or between commits.
2. git log
: Explore Your Project History
git log
helps you see a list of all the commits that have been made in a repository.
3. git clone
: Copy an Existing Repository
git clone
lets you make a full copy of a Git repository from a remote source (like GitHub) to your local machine.
git clone https://github.com/username/repository.git
This creates a directory with the entire project history and working files.
4. git pull
: Bring Changes from Remote to Local
git pull
fetches the changes from the remote repository and merges them into your local branch.
git pull origin main
This fetches and merges the changes from the main branch on the remote.
5. git blame
: Track Who Changed What
git blame
shows who last modified each line of a file and when.
6. Git Merge Conflicts: When Things Don't Auto-Merge
Merge conflicts happen when Git can’t automatically resolve differences between branches. This usually happens when two people edit the same line in a file or delete a file that someone else modified.
7. git branch
: Manage Code Versions
git branch lets you create, list, rename, and delete branches. Branching is key to isolating work, like developing new features or fixing bugs, without affecting the main codebase.
Common usage:
git branch — lists all branches.
git branch new-feature — creates a new branch.
git checkout new-feature — switches to that branch.
git checkout -b new-feature — creates and switches in one command.
8. .gitignore
: Tell Git What to Skip
The .gitignore
file tells Git which files or directories to ignore in a project.
Use cases:
- Ignoring sensitive files like .env.
- Skipping OS-generated files like .DS_Store or Thumbs.db.
- Excluding build artifacts or dependencies like node_modules/.
node_modules/
.env
*.log
9. GitHub Wiki: Documentation Made Easy
Every GitHub repository can have its own Wiki — a place to host documentation, guides, project notes, or anything related to the repo.
Why it’s helpful:
- Keeps project documentation organized and accessible.
- Great for onboarding new contributors.
- Easy to edit via the GitHub UI or clone and update like a regular Git repo.
To use it:
- Navigate to the “Wiki” tab in your GitHub repository.
- Click “Create the first page” to start documenting.
- You can even clone the Wiki using git clone
https://github.com/username/repository.wiki.git.
Final Thoughts
Git is much more than just add
, commit
, and push
. Understanding commands like git diff
, git blame
, or how to resolve merge conflicts
will give you more control and confidence in your version control workflow. Combine that with good practices like using .gitignore
and documenting your projects with GitHub Wiki
, and you'll be collaborating like a pro in no time.