2

I have an existing GitHub repository that was linked to a Visual Studio Community 2017 project on my local machine. I had made two commits and pushed them to GitHub.

I've modified the project from a secondary directory on my local machine-essentially, I have two copies of the same project-and used File Explorer (outside of Visual Studio) to copy and paste the modified version into the directory of the version that was linked to GitHub.

When I open my project that was linked to GitHub in Visual Studio, I no longer seem to be properly connected. I've made attempts at re-establishing the original connection, but I'm coming up short. I've deleted my GitHub project folder, cloned my GitHub repo (from the former pushes), and copied my secondary (modified) project folder back into the GitHub project folder. My status bar in Visual Studio does show three commits and a branch named the same as my original branch. When I view the Synchronization page of Team Explorer, I can see my latest Commit under Outgoing Commits; and a message states that "The current branch does not track a remote branch. Push your changes to a new branch on the origin remote and set the upstream branch."

Is there a way to reconnect my project to the repo to push my changes on the original branch?

sd-mustang
  • 17
  • 3

2 Answers2

0

At least, in your new local repo, check:

git remote -v
git branch -avv

Make sure origin reference the right remote URL.

If your branch is not linked to its upstream branch, you can restore that link with:

git branch -u origin/myBranch myBranch

Then open Visual Studio again, and see if it has picked up on those settings.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I had a little in-person help with this issue. Unfortunately, I cannot provide a step-by-step procedure that was used to solve the issue; but the Rebase and Merge methods available for Branches in the Team Explorer of Visual Studio were part of the solution. I am now able to push again without trouble to my GitHub repository!

sd-mustang
  • 17
  • 3