How to connect a local GIT repository to a remote GIT repository hosted in GitLab?

Jaime Stuardo 51 Reputation points
2020-09-26T17:29:49.737+00:00

Hello,

I have created a VS2019 solution and a local GIT repository for it. Then I created a GitLab repository. Finally, In local repository configuration, I have added the remote connection.

After all of that, and try to commit, VS2019 tells me that I am not connected to remote repository so I always can commit the source code to local repository. To push to remote repository I have to use the external Git GUI tool.

On the other hand, I have other VS2019 projects that I could connect using this same procedure, and other by cloning the remote repository.

It is really frustrating that Microsoft thinks that all people uses its own version control system such as Azure DevOps or Team Foundation Server so generally it is a real pain when trying to connect to other kind of repository.

Any help will be appreciated.

Thanks
Jaime

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,742 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 28,341 Reputation points Microsoft Vendor
    2020-09-29T09:13:15.867+00:00

    Hello Jaime,

    Thank you for explaining and sharing more information with me. Does the “connect both branches” mean there are some contents (like changes in Project A) and you’d like to confirm these changes and write(merge) them into Project B(remote branch)? Or you want to push the local branch to GitLab as a new branch?

    If you want to confirm changes and write(merge) them into remote branch, I’m afraid you need to use git command. And, actually, in Visual Studio, we usually try to clone remote repo, then modify the file(project), after that confirm changes > Sync. Or, if the project was cloned to local repo, and before modify something, we usually use pull to synchronize. But for a newly created(existed) branch, you may need to use git command.

    If you want to push local branch to GitLab as a new branch, you can try to click the Push Branch option from Team Explorer > Home > Branches > find your branch and right-click it > Push Branch.

    29074-pushbranch.png

    Sincerely,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments