I am using Git 1.7 version as our repository .
I have done some change to my local file as part of development process(ie in my Eclipse Workspace )
Every day as soon as i come to office , i do check in the latest code from the Remote Repository using git pull command .
Today when i did the git pull command , i got the following error .
$ git pull
Updating 2be0f0d..e2f796e
error: Your local changes to the following files would be overwritten by merge:
LoginServlet.java
Please, commit your changes or stash them before you can merge.
Aborting
My question is that , is it mandatory for me to do a git add ( To add my files to the staging area , because my concern is the file is not code at , its in process)
( Is it required to add my file to the staging area , which is still being coded )
Adding it to stage area would not help. The message tells you simply that someone made changes to the file LoginServlet.java on remote repository, and that causes conflict with your local changes.
This also means you are running pull in dirty work directory. To download recent changes, you should temporarily set aside your local changes, do the pull, and then get your local changes applied on top of new remote state.
This is what
git stashis for. What you probably want to do is something like this:There are no general rules when to put stuff in staging area.