1

I´m developing a project using github and visual studio github extension.

I uploaded a running version of the code and keep on developing

In the meanwhile, some other coder updated the git files with plenty of errors and then basically disappeared. My local version is still Ok. I want to upload MY LOCAL version of the code, which includes the old state plus changes

So what I want is to push my files ignoring anything in the repo. I could even just create a new one but I have some pipelines and would be a bit of a mess.

I guess another valid approach is to revert all new commits he did and once GIT is in the state of my last commit, then procede to do standard commit from VS.

But github desktop or VS git extension doesn't allow me to do so.

Any clue?

PS: I´ve never use git on command line so if the solution goes through this.. please be very detailed on your answer :)

javirs
  • 1,049
  • 26
  • 52

2 Answers2

0

In VSCode go to your git and ... than Changes and do Stage All Changes. After that you can check each file and push the verion you want.

That worked for me. Hope it helps

VOXDelta
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 28 '23 at 23:49
0

It is easier to open a CMD terminal in your VSCode, at the root folder of your project (which should be the root folder of your repository) and type, assumuing you are both working on main:

git add .
git commit -m "Commit everything locally"
git fetch
git merge --ours origin/main
git push

See "Why would one use "git merge -s ours"?": the idea is to ignore the changes pushed to origin/main and keep your local main content.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This won't delete things he changed and I didn't or files he created. Isn't it? I want an exact copy of what's now in my side – javirs Mar 24 '23 at 10:21
  • @javirs That is what it will do: keep only what you have. – VonC Mar 24 '23 at 10:34
  • As I said I have no experience with command controls. Where does one run that. Just in the windows CMD ? – javirs Mar 24 '23 at 14:51
  • @javirs You can use [Git in the built-in terminal](https://code.visualstudio.com/docs/sourcecontrol/intro-to-git#_using-git-in-the-builtin-terminal). No need to leave VSCode. – VonC Mar 24 '23 at 14:53
  • Im not in VS code. im in VS Studio using git plugin, in the git changes window – javirs Mar 24 '23 at 15:38
  • @javirs Than you should have (in Visual Studio) [an "Open in Terminal" option](https://learn.microsoft.com/en-us/answers/questions/174070/command-line-git-in-vs2019#answer-244221). See also "[How can I use a git bash terminal profile in Visual Studio 2019?](https://stackoverflow.com/q/62109412/6309)". – VonC Mar 24 '23 at 15:47