Why do I get files without a trace after git pull (files were moved on the remote control)

Running git pull created some unplayable files in my local copy. Files were moved on the remote control, but attraction did not delete the files in my working directory. I spent a lot of time studying this, but I can not find such cases. Is this the intended behavior, am I missing something, or both?

Background

I made a patch and sent it to the open source project developers, but then I wanted to remove the local commit and git pull β€œofficial” patch after it was committed to the remote computer. So I did a bunch of β€œthings” before resetting the previous official HEAD. "Stuff" means things like git checkout -- <file> , git reset HEAD^ and other commands that I can't remember since I'm new to git and I'm trying to research best practices.

Anyway, after I finally unzipped my commit and did git pull , I got 66 commits for changes, including my patch, and everything looked great. But then git status showed that two files were not tracked. I made gitk <untracked_file1> and I saw that about 20 commits ago, the file was moved to another directory. The file now exists in the new location, but instead of deleting the old file, it appears as unsolicited.

I tried to hard reset according to these instructions , but the files are left without a trace. I can do git clean -f to clean them, but I wonder why the files are not deleted automatically.

+5
source share
1 answer

git pull does not delete uncommitted changes, this does not apply to your working directory, any changes or new files will not be affected if they were not committed.

to learn more about the state of any git repo, read the following:
https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

and also, to reset your local branch to the remote one, instead of a bunch of things, you can use the following commands:
git fetch --all
git reset --hard origin/<remote_branch_name>

+2
source

Source: https://habr.com/ru/post/1243550/


All Articles