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:
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.
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