Home > database >  Git - Commit and push local changes without losing file diffs?
Git - Commit and push local changes without losing file diffs?

Time:05-07

I'm in VSCode and just made a ton of changes on my branch. I have a rough draft that would be a shame to lose due to to not backing up online. So naturally it would be smart to git add . my changes, then git push origin myBranch to create a remote backup.

But doing so will remove all my file diffs that Visual Studio Code's interface shows me in the sidebar (see picture below). Is there a way I can push to a remote branch but still keep the changes unstaged (or bring them back to unstaged), or any way to at least keep those diff files so I can still continue work on my local and easily be able to see everywhere that I touched?

7 files changed, clicking here will show all my diffs

CodePudding user response:

what will you push if you don't have any changes?

simple solution will be . keep a copy all the files that you have made changes, then undo changes.

later you can refer to the changes from copied files

CodePudding user response:

save your work by using git stash. after pushing committed changes then you can call uncommitted changes as git stash pop. see the documentation here

  • Related