Git Episode 4: How to create a new branch with main branch files
Branches allow you to work on new features or fixes without touching the main code (usually the master or main branch). Once your work is…
Wiki topics:
🔓 · Open Source
Git Episode 4: How to create a new branch with main branch files
Branches allow you to work on new features or fixes without touching the main code (usually the master or main branch).
Once your work is ready, you merge it back into the master branch.
✨ Part 1: Creating a New Branch
You have two ways to create a branch. Let’s look at both.
✅ Recommended Method: Clone → Create Branch
This is the cleanest and most common method.
Steps:
- Clone the repository:
git clone https://github.com/<owner-or-org>/<repo>.git
- Go into the project folder:
cd folderName
- Create a new branch (let’s say you want a create branch which name is “new”:
git checkout -b new
- Push your new branch to GitHub:
git push -u origin new
🎉 Your branch is now created!
✅ Bad Method (Not recommended) : Clone → Create Branch
- Download the project ZIP from GitHub and extract it.
- Open the folder in your terminal:
cd folderName
- Initialize Git:
git init
- Create a new branch:
git checkout -b new
- Add all project files:
git add .
- Commit the changes:
git commit -m "first commit after new branch"
- Connect to your GitHub repository:
git remote add origin https://github.com/<your-username>/<repo>.git
- Push the new branch:
git push -u origin new
🎉Your branch is created !!
Hit the clap button if this blog helped you. See you🙋♂️
메타데이터
- post_id
- a9e969eb0c95
- slug
- git-episode-4-how-to-create-a-new-branch-with-main-branch-files-a9e969eb0c95
- url
- https://medium.com/@shahmarufsirajmugdho/git-episode-4-how-to-create-a-new-branch-with-main-branch-files-a9e969eb0c95
- canonical_url
- https://medium.com/@shahmarufsirajmugdho/git-episode-4-how-to-create-a-new-branch-with-main-branch-files-a9e969eb0c95
- author_url
- https://medium.com/@shahmarufsirajmugdho
- status
- ok
- fetched_at
- 2026-08-18 14:54:50