Git keep some local changes clean but do not push them

I am working on the develop branch on my computer. I have done a lot of changes that I do not want to push, but I want to keep them. What I did is to change the translator behavior on my project and I would like to test it a little longer before pushing it and deploy it to production. But I would like to continue to work on develop or any other branches and be able to apply theses changes.

There is the ideas I came up with:

  • Keep all of those files (do not git-add them) and commit only files I actually want to commit. But this solution make my "git status" very messy (lot of modified files) and I believe it will generate errors and lead to the commit of wrong file(s).

  • Git stash save "Translation" and apply it when I want to use it. But I will have the same issue with a messy git status where I will have to choose which one of my files I want to commit or not.

  • Create a new branch with my new feature on it, but as soon as I will merge it to my working branch I will commit the merge as the same time

  • Do you know any other workflow to keep a list of changes to a lot of files and apply/remove theses changes ?


    Something like git-flow or gitlab-flow suits very well.

    From what I've read, I can conclude that your project consists of 2 modules, and you modify both of them.

    One module is stable, but you've modified it anyway and want to test your modifications more thoroughly, and another one is a work in progress.

    I would use your 3rd variant, but merge your working branch into your new feature branch.

    Or, if you want to separate your modifications to a "stable" module, you could keep them in a separate branch.

    That is, you get 3 branches:

  • your work on "unstable" module, "stable" module without your latest changes;
  • your modifications of "stable" module;
  • merge of two above
  • Branching in git is cheap and easy, you can create any amount of branches.


    You could have your main local branch rebase onto an intermediate branch that is the one tracking the distant branch. You then report your commit from yor main local branch to the tracking one via cherry-pick, and then rebase your main local onto the updated tracking branch.


    Keep the local unfinished work on a separate branch and push it.

  • It will allow you to craft commits properly and not do a huge monster commit at the end.
  • It will allow you to have a copy of your code on the server so that in case of a disk crash or something similar, you won't lose your work.
  • It will allow others to see your code and review it before you deploy to production.
  • The deployment will happen usually off a single branch. As long as you don't merge your changes into that branch (though you need to verify this at your place), you're safe.

    链接地址: http://www.djcxy.com/p/49818.html

    上一篇: 不成功的git push - 不能再次推送

    下一篇: Git保持一些本地变化干净,但不要推动它们