Home > Mobile >  problem in git sync or git pull when I delete my local file?
problem in git sync or git pull when I delete my local file?

Time:07-20

I have cloned my remote repo to the local machine. I deleted some files from my local but when I use git sync or git pull to get my missing files from remote repo, Tortoise git show me everything is update!!! but nothing is happened and my local repo is same as before , I do not have my missing files.

I have to clone my remote repo again. Is there a solution?

CodePudding user response:

The git pull isn't recovering your files because, as far as git is aware, you have the same commits locally as are on remote. Assuming these files are local, what you're probably looking for is git reset (if you want to reset to a specific commit) or git checkout -- <file> if you're trying to reset an individual file. NOTE: if you've committed the changes and they are several commits back or already pushed do git revert.

  • docs on TortiseGit reset.
  • TortiseGit considers reverting an individual file under revert. See the docs.
  • Should you need to undo a far back commit, see the relevant pages referenced in the previous link.

If you've already create a commit (the latest one being the deletions) you can reset to the previous commit and then revert the files you want to keep. Just be careful. If you have other changes within the same commit that you want to keep, you'll want to do a mixed reset instead of a hard one.

Side note: I strongly recommend embracing the CLI git tool at some point. It's incredibly powerful and has a lot of useful functionality that many GUI tools simply don't support. However, TortiseGit is very mature and has a lot of functionality compared to other GUIs I've used.

  • Related