I have been using git (Gerrit) from last one month with visual studio 2015 with update 3. All of a sudden I have started encountering the error "******Error encountered while fetching: Invalid redirect to different host"******. I checked different forums for the answer, however nothing worked. I tried disconnecting from all TFS server and also I tried to create a new repository. However I am facing the same issue. Any help will be appreciated. Let me know if you need more info on this.
Asked
Active
Viewed 501 times
0
-
Since you are using gerrit for code review, the remote git repo you connect is mainly located in your gerrit server? You can double check the remote url by Team Explorer -> Settings -> Repository settings -> Remotes. And how do you connect the git repo in VS if your git repo does not locate in TFS or VSTS? – Marina Liu Feb 27 '18 at 03:13
-
As mentioned by you, I have checked the remote url (fetch url and push url) in repository settings and seems like it has a proper url (format :** "http://[user name]@[repository url]/[project name]"**). Also I have verified the same in config file under .git folder as well and seems to be ok. However the issue still exist – Rohit Feb 27 '18 at 09:25
-
So does the remote repo url under your gerrit server? Does the remote repo not TFS or VSTS git repo? So how did you clone the remote repo by VS? – Marina Liu Feb 27 '18 at 09:29
-
yes, The remote repo is in the Gerrit server and we clone the code using VS team explorer --> Add git repo --> provide the url and clone. – Rohit Feb 27 '18 at 09:37
1 Answers
0
Since the remote url is for gerrit server, you should push to gerrit by the command:
git push origin HEAD:refs/for/branchname
While if you push changes by VS, VS just execute the command git push origin branchname
instead.
More details, you can refer git push for Gerrit, and the post Why is git push gerrit HEAD:refs/for/master used instead of git push origin master.

Marina Liu
- 36,876
- 5
- 61
- 74