Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull (update local file only)

Tags:

git

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

like image 511
LynAs Avatar asked Jun 18 '12 15:06

LynAs


2 Answers

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!

like image 103
bilalq Avatar answered Nov 12 '22 04:11

bilalq


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
like image 41
vgonisanz Avatar answered Nov 12 '22 04:11

vgonisanz