Master GitHub merging with our step-by-step guide: install Git, create branches, commit changes, open pull requests, resolve conflicts, and clean up your repo.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Install Git and Create a GitHub Account
First, you need Git installed on your machine and a GitHub account.
git --version
Step 2: Configure Git with Your GitHub Credentials
Tell Git who you are so commits show proper attribution.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global --list
Step 3: Create or Clone a Repository
You can start a new project or work on an existing one.
git clone https://github.com/username/repo-name.git
cd repo-name
Step 4: Create a New Branch for Your Changes
Working on a branch keeps main clean and simplifies collaboration.
git branch
git checkout -b feature-branch-name
feature-branch-name
.feature/
, bugfix/
).
Step 5: Make Changes and Commit Them
Edit files using your editor or IDE. When you’re ready to save changes:
git status
git add file1.txt file2.js
git add .
git commit -m "Add feature X to improve Y"
Step 6: Push Your Branch to GitHub
Publish your branch so GitHub can see it.
git push -u origin feature-branch-name
-u
flag sets origin/feature-branch-name
as the default upstream.git push
.
Step 7: Open a Pull Request on GitHub
On GitHub.com, navigate to your repository. You’ll see a banner prompting you to compare & pull request.
Step 8: Review, Resolve Conflicts, and Discuss
Team members review your PR and may request changes.
main
and rebase or merge:
git fetch origin
git checkout main
git pull
git checkout feature-branch-name
git merge main
# or: git rebase main
git add conflicted-file.txt
git commit # if merging
git rebase --continue # if rebasing
git push # may need --force if rebased
Step 9: Merge the Pull Request
Once approved, merge your feature branch into the main branch.
Step 10: Clean Up Branches
After merging, delete stale branches to keep the repo tidy.
git branch -d feature-branch-name
git push origin --delete feature-branch-name
main
and pull the latest changes:
git checkout main
git pull
Step 11: Celebrate and Repeat
You’ve successfully merged changes using GitHub! Continue the cycle for future features and fixes.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.