Manually Configure Remote Repo And Remote Branch Tracking - egnomerator/misc GitHub Wiki

Process: Update the .git\config File

  1. Specify remote repository connection information by adding the repository clone URL and fetch specifications to the config file
[remote "origin"]
	url = https://myGitHost.com/myNewGitRepository
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
  1. Add remote branch tracking by specifying the following in the config file (assuming that "master" is the name of the branch to track in the remote repository)
[branch "master"]
	remote = origin
	merge = refs/heads/master

My Scenario TLDR

I wanted to push my local-only Git-tracked work to a freshly created remote repository without losing my local-only Git commit history.

For work, I was creating a new application. I began work on a local solution which I tracked with Git (only locally). I eventually was ready to push the initial solution to a new (non-existing) Git repository in our team's VSTS account.

My permissions in the team VSTS account are limited, so I could not publish my local solution to a new Git repository in VSTS. I had to ask my manager to create the new VSTS repository.

Normally if I want to contribute to one of our team's VSTS repositories, I would clone it, write my code, commit, and push my work to the remote repository. But, I couldn't follow that workflow in this scenario, because I'd lose my local Git commit history.

Following the above process allowed me to connect my previously local-only Git work to the remote repository and push my work to the tracked remote branch along with the local commit history.

⚠️ **GitHub.com Fallback** ⚠️