git - Local repository for test branch - Stack Overflow

admin2025-05-02  1

I want to create test branch for testing purpose which is hosted in local repository server, before eventually pushing to master branch in remote repository server. What are the correct steps required?

I want to create test branch for testing purpose which is hosted in local repository server, before eventually pushing to master branch in remote repository server. What are the correct steps required?

Share Improve this question asked Jan 2 at 4:43 maspaimaspai 4351 gold badge6 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Suppose you have remote repository https://github.com/user/repository.git with master branch. To create a new local branch, you have to follow the steps below:

Create a new directory and initialize git repository.

mkdir repo
cd repo
git init

Add remote repository.

git remote add origin https://github.com/user/repository.git

Pull files from remote repository.

git pull origin master

Create a new branch.

git branch test

Switch to new branch.

git checkout test

Start modifying your new branch, do some commits, etc.

To push to your remote repository, just run:

git push -u origin test
转载请注明原文地址:http://www.anycun.com/QandA/1746134246a92049.html