Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Git Commands

This document provides a step-by-step guide for pushing both main and dev branches to a new GitHub repository. It includes instructions for creating a repository on GitHub, setting up a local repository, ensuring code is in the dev branch, adding and committing code, linking to the GitHub repository, and pushing both branches. Finally, it advises verifying the existence of both branches on the GitHub page.

Uploaded by

Stevany Corleone
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Git Commands

This document provides a step-by-step guide for pushing both main and dev branches to a new GitHub repository. It includes instructions for creating a repository on GitHub, setting up a local repository, ensuring code is in the dev branch, adding and committing code, linking to the GitHub repository, and pushing both branches. Finally, it advises verifying the existence of both branches on the GitHub page.

Uploaded by

Stevany Corleone
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

You want to push both main and dev branches to a new GitHub repository, where your current

code is in the dev branch locally. Follow these steps:

1. Create a New Repository on GitHub


1. Go to GitHub.
2. Click the + icon at the top right and select New repository.
3. Fill out the repository details:

· Repository Name: Name your repository.


· Visibility: Choose Public or Private.
· Initialize Repository: Do not check "Add a README."

4. Click Create Repository.

2. Set Up Your Local Repository


1. Open a terminal or command prompt.
2. Navigate to your local project folder containing the code:
cd /path/to/your/folder

3. If not already done, initialize your local repository:


git init

3. Ensure Your Code is in the dev Branch Locally


1. If you're currently on the dev branch, verify with:
git branch

2.
3. If dev is listed and highlighted, you're already on it.
4. If not, create and switch to the dev branch:
git checkout -b dev

4. Add and Commit Your Code


1. Add all files to the staging area:
git add .

2. Commit the changes:


git commit -m "Initial commit on dev branch"
5. Link to the GitHub Repository
1. Copy the repository URL from the new GitHub repo (e.g.,
https://github.com/username/repo-name.git).
2. Add the remote origin:
git remote add origin https://github.com/username/repo-name.git

6. Push Both Branches to GitHub


1. Push the dev branch:
git push -u origin dev

2. Create and push the main branch:


git checkout -b main # Switch to main git push -u origin main

7. Verify Both Branches on GitHub


1. Go to your GitHub repository page.
2. Use the branch dropdown to ensure both main and dev branches exist.

You might also like