How to delete a file from git repo on local and remote

I wish I knew git better.

I have some project settings files in my repo that conflict with a colleague every time we transfer our project. It is not entirely clear why, but this is the time when these files were deleted from the repo due to the noise they created. I can't make it work to save my life.

Before starting, I made sure that my branch was completely updated using the remote control. Then i used

 git filter-branch -f --index-filter \ 'git rm -r --cached --ignore-unmatch *.csproj' HEAD

I added a flag -fdue to some backup problem, since I ran it a couple of times.

Running this command seems to remove all files from my repo. However, when I try to push this change to the server, it gives an error saying that my repo is 2 commits for the remote version. He recommends that I pull, and then cancels the command above.

What am I missing to get this change on my server? (BitBucket)

+4
source share
1 answer

If I understand your problem correctly, you cannot click on the remote repository because your local history does not correspond to the deleted history. This is what usually happens when you locally change the hit commit with rebaseor filter branch.

, . , , git pull, . - , , , , filter-branch.

, , --force git push. git push --force origin master. , , , , git.

, , , , - , .

: , . fetch/reset, rebase.

fetch/reset . :

git fetch origin && git checkout master
git reset --hard origin/master

rebase . . , , .

git fetch git rebase -i origin/master

, , , . , , .

SO-, : git pull

+2

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


All Articles