I had to switch my workspace. instead of git clone I did git remote add . unknowingly I had committed so much works in my local repository. now I want to push to remote master. but the pull request shows all files changed. How can I clone my new local repository with the remote repository without affecting the committed files of my local repository, so that I can only see the files I changed lately. I wonder if this is possible ? Thank you in advance
-
I'm a bit confused by your question. Can you spell out, step by step, every Git command you ran to end up in this situation? – Tim Biegeleisen Jan 29 '16 at 14:49
-
The thing is I am working in my remote repo. I switched my laptop, so i had to do fresh pull from remote to setup new local repository. But instead of git clone , I did git remote add origin, and i have works committed in my new local repository. while creating pull request to remote branch it shows whole files changed or modified instead of just few files i changed... its like im pushing a whole new repo to my remote master – Niroj Shr Jan 29 '16 at 14:55
1 Answers
Remember that git is a distributed version control system. Any differences are relative to any two copies of a repository you are comparing. Given that point, let's review your question:
You have a local dev environment at your previous workspace. If you had any commits local to that repository that were never pushed to the remote repo, they're out of scope for this problem.
You set up a new local dev environment, which I'll call WS2. If I understand your point, WS2 is showing that all files have been edited when compared to your remote repository.
Okay, now what?
Possibility 1 - You could avoid this by status by first pulling your remote in order to show the diff:
git remote add origin git@github.com:mjb/repo.git
git fetch origin master && git pull origin master
# make your edits to files
git add .
git status
# this should show only the difference now
Possibility 2 - You're having trouble with case-sensitive file names, which is well explored here: Files showing as modified directly after git clone
-
had to clone the repo again and redo the works done ... hope someone has solution for this – Niroj Shr Jan 30 '16 at 06:37