This guide explains the basic steps to work with Git in a simple way. It covers cloning a project, working on branches, saving your work, and keeping your fork updated.
Git is a tool that helps you track changes in your code and work with others without overwriting each other's work.
Tell Git who you are:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Cloning means copying a project from the internet to your computer.
git clone <repository-url>
cd <repository-folder>
A branch is like a separate workspace. You should never work directly on the main branch.
git branch my-branch
git switch my-branch
Or create and switch in one step:
git switch -c my-branch
git branch
git branch -d my-branch
git status
git add .
git commit -m "Write a short message about your changes"
Always push to your own branch, not main.
git push origin my-branch
Get updates from the remote project:
git pull origin main
If you forked a project, you need to keep it updated.
git remote add upstream <original-repo-url>
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
git checkout branch-name
If you want to switch branches but are not ready to commit:
git stash
git stash list
git stash apply stash@{n}
git stash drop stash@{n}
- Clone the project
- Create a new branch
- Make changes
- Add and commit
- Push to your branch
- Create a pull request (on the website)
- Never push directly to main
- Always create a new branch for your work
- Write clear commit messages
- Pull latest changes before starting work