10

i just want to update my local files with git. but every time i try to pull i get and error saying that i need to commit certain file first. what is the way to update local file without using commit??

here is the error message

$ git pull Enter passphrase for key '/c/Users/me/.ssh/id_rsa': Updating 4dsdSe6e..70fb5b6 error: Your local changes to the following files would be overwritten by merge: grails-app/conf/DataSource.groovy Please, commit your changes or stash them before you can merge. Aborting

2 Answers 2

19

If you don't want to commit, you'll need to stash your changes. This sounds like what you're looking for:

git stash save "Changes I don't want to commit yet" git pull git stash pop 

The first line stashes your changes onto a stack and reverts your code to the last commit. From there, you can pull like normal. Once you've pulled, pop the changes in your stash back onto your code. This let's you do a pull without committing your code. You can learn more about stashing here.

Hope that helped!

Sign up to request clarification or add additional context in comments.

1 Comment

No problem. However, do note that committing your changes is not the same as pushing them to the remote repository. It's good practice to commit early and often in git. If you're coming from a CVS background, this might seem strange, but it's part of what makes git so powerful and versatile.
3

You are trying to pull some files that will delete your changes. First, commit your changes with:

git commit -a -m "I have changed XXXX" 

then pull others:

git pull 

If no problems to solve, you can push your changes:

git push 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.