How can I revert my project's Git repo without breaking Visual Studio?

244 views Asked by At

What's the least painful way to get my git repository into the state I need it for our Visual Studio project?

In Visual Studio terms, we started with a Web Site Project. The current production version of the site is mostly an (old) branch of that Web Site Project aside from a few critical fixes that have been made to production.

We brought in some contractors to add a new feature to the site, and they took our code and imported it into a (new) Web Application Project, and then they updated files and sent us a pull request. Because the file paths were so different and a few other changes were rather painful, I converted the dev branch of our Web Site Project into a Web Application Project, relocated files to match the new paths, and then merged their changes in, manually fixing all the merge conflicts between their new Web Application Project and our converted Web Application Project (and if you have never manually fixed merge conflicts in a Visual Studio project's XML configuration files, consider yourself lucky).

So if you picture our git repo, there are now two branches in question: dev, which has become a Web Application Project, and prod, which is still a Web Site Project, and which is slightly out of sync with the actual production site for … reasons.

The client hasn't approved the changes in dev, and isn't likely to approve them any time soon; they do, however, need a critical change made to production that (unlike previous hotfix changes to production) is of large enough scope that it needs to run through a full dev/qa/approval process.

There are, at this point, advantages to having the whole site be a Web Application Project (advantages that weren't relevant when the site was created as a Web Site Project and checked into git in the first place). What's my best plan of attack for git, that won't result in a broken project in Visual Studio but will get me to a new or reverted dev branch that is both a Web Application Project and consistent with the actual state of production?

I know it's probably going to involve at least one new branch to handle the merge between production code and the dev branch's Web Application Project structure, but I don't know where to start. Do I check out dev over the top of prod? Prod over the top of dev? A new empty branch where I check them both out in some order?

2

There are 2 answers

0
Vladimir Atamanenko On

I'm not very familiar with Visual Studio, but I think you should convert project from production branch to Web Application Project and make file paths in dev branch and file paths in production branch as similar as possible and then merge them.

2
whoisj On

Visual Studio uses Git. Not some kind of VS-only Git.

My recommendation is to create a new branch, I'll call it web-app-feature.

So git checkout dev, git branch web-app-feature. Now you have a new branch pointing to the same commit as dev. Now we need to move dev to master which in Git is very simple. Perform a git reset --hard master which instructs the current HEAD (which is dev because it was our last checkout) to point the same commit as master.

Now your repo looks a little like *-*-*-*-*<- master, dev | *-*-*-*-*-*<-web-app-feature