• Register
0 votes

Problem :

How can I ignore the below error message on the Git pull?

Your local changes to the following files would be overwritten by merge

What if I just want to overwrite them?

I Have already tried many things like git pull -f, but nothing really works for me.To be very clear, I just want to overwrite the specific changes and not the everything.

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

  1. If you just want to remove all your local changes from the working copy, just stash them with the below command :

         git stash save --keep-index

  1. If you just do not need them anymore then you now can simply drop that stash with the below command :

         git stash drop

If you really want to just overwrite the specific parts of your local changes, there are two possibilities as shown below :

  1. Commit everything that you don't want to get overwritten and use the method above for the rest.
  1. You can use git checkout path/to/file/to/revert for your changes those you wish to overwrite. Also please make sure that your file is not staged via git reset HEAD path/to/file/to/revert.

If you follow above mentioned procedure then you will surely fix your all above mentioned issues.

9 7 4
38,600 points

Related questions

0 votes
2 answers 171 views
Problem : I have the project with two branches as staging and beta. I try to develop on staging, and use my master branch to fix the bugs. git checkout master And do the stuff on it : git add fileToAdd git commit -m "bug fixed ... be overwritten by checkout: src/Pro/ConvocationBundle/Controller/DefaultController.php Please, commit your changes or stash them before you can switch branches. Aborting
asked Dec 18, 2019 alecxe 7.5k points
0 votes
2 answers 3K views
Problem : On the branch I had some files in the .gitignore On the different branch those files are not. I am trying to merge the different branch into my branch, and I don't bother if those files are no longer overlooked or not. Unfortunately I get below ... by merge” How should I modify the pull command to overwrite those files, without needing to find, move or delete those files by myself?
asked Jan 6, 2020 alecxe 7.5k points
1 vote
2 answers 1.6K views
Problem : On the branch which I had some of my files in .gitignore On the different branch those files are not present. So I want to merge the different branch into my branch and I really do not care about those files if they are no longer ignored or not. But ... by merge How can I modify the pull command to overwrite the files, without me needing to find, move or delete the files by myself?
asked Dec 27, 2019 alecxe 7.5k points
0 votes
1 answer 173 views
Problem : I added the folder to the .gitignore file. Once I do the git status it tells me # On branch latest nothing to commit (working directory clean) But when I try to change my branches I get the below: My-MacBook-Pro:webapp marcamillion$ git checkout develop ... /system/images/* public/system/avatars/* How do I get this working for me so I can switch my branches without deleting those files?
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 237 views
Problem : I have recently started using Git. I am still learning about Git. I tried to do the pull from the remote repository. But now I am facing below error message: "Please enter a commit message to explain why this merge is necessary, especially if it merges an ... nothing is really happening for me. How can I fix the above error message. I am currently learning to use terminal on the OS X.
asked Mar 3, 2020 mphil 2.3k points
0 votes
1 answer 34 views
Problem: I have basic knowledge of GIT. Whenever I try to pull in my project directory in my terminal then I face the below error: /Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible because you have ... 'git commit -a'. Why does my git is showing me above error? and how can a beginner like me fix above git pull error?
asked Aug 27, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 55 views