0

I have my whole production code in a repository and locally I had to changed some backend/frontend code out of neccessity and leave them in a permanant "unstaged change" mode.

Since I did all the test locally, I didn't need to use branches until today.

We now have a dev branch and I commit my changes to dev then checkout master and git merge dev.

The only issue is that anytime my change happens to one of those unstaged files, I get the famous:

Please commit your changes or stash them before you switch branches.
Aborting

This answer somehow helps https://stackoverflow.com/a/22424970 but this is not an efficient way for me to do this on every commit.

Is there any way I can do less work on each commit/merge?

d9ngle
  • 1,303
  • 3
  • 13
  • 30
  • I see potentially contradictory things in your description. You mentioned that you committed all your changes before attempting the merge. If so, then you should not be seeing the warning message about uncommitted changes. I don't understand your workflow here. – Tim Biegeleisen May 28 '20 at 16:39
  • Not all of them, the part that is new is commited, rest stays. – d9ngle May 28 '20 at 16:40
  • You could remove these files from git control. – matt May 28 '20 at 17:17
  • @matt not my use case, I'm still working on these files and developing them... only cherry picking which part gets commited using my IDE – d9ngle May 28 '20 at 17:24
  • What's the **necessity** that prevents you from committing the files in question to some branch? – Caleb May 28 '20 at 17:40
  • Maybe "assume unchanged"? "https://stackoverflow.com/questions/1753070/how-do-i-configure-git-to-ignore-some-files-locally" – Ouss4 May 28 '20 at 18:57

1 Answers1

0

Not all of them, the part that is new is commited, rest stays.

Okay, but that's your problem. A file is the atomic unit of thought in git. You cannot mark just a part of a file as outside of git's purview. If you show any of a file to git, git now knows about the whole file and sees (and rightly says) that you've modified. And that is what you are doing.

So, you have conflicting desires. Basically if you're going to work this way, then you have to live with the consequences.

matt
  • 515,959
  • 87
  • 875
  • 1,141