Mark Downes
Mark Downes

Reputation: 1

How do I create and push a local git branch in Visual Studio for Mac 8.9

I am wondering how I can create a local git branch in Visual Studio for Mac 8.9 and then push it to the server. I tried clicking on Version Control -> Manage Branches and Remotes. Then I tapped on the ‘New’ button, typed in a name for the branch. When I tap on OK I get a local branch but I can’t seem to figure out how to push that branch to the server.

Upvotes: 0

Views: 1143

Answers (1)

Akshay Bhat
Akshay Bhat

Reputation: 314

I assume you are trying to push a new project that you have created to GitHub. Let me help you with the step by step process to do that.

Open the terminal in VS code first.

  1. In your machine initialize a git repo by using the command git init -b main.
  2. The above command will create a main branch now you can run git status to verify the changes you want to push.
  3. Now if you have to push all the changes you need to stage them first and you can use git add . for that.
  4. After this you need to commit the changes for that you can use the following command git commit -m "custom message". Note you can type any commit message here.
  5. Now you need to go to github web and copy your repositories URL if already created. If not you will need to create a new repository first. As shown in the screenshot below you need to copy this URL. enter image description here

6. Now you need to set the remote for that you can use git remote add origin <REMOTE_URL> replace the REMOTE_URL with the repository URL that you copied in the 5th step. 7. Everything is setup now you just need to push your changes for that you can use the command git push origin main. This will push your changes to the main branch that we created in the first step.

After doing all this you should be able to see your changes on github for more detailed steps you can check this out . https://docs.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line

Hope this helps

Upvotes: 1

Related Questions