I’m using git, and I’d like to be able to create a commit which isn’t synced with the remote repository. Such a commit would have to “float” atop all other commits in the local repository to avoid affecting the history. I could use such a commit to store local-specific changes (configuration changes, debugging flags, local workarounds, etc.).
Currently, I manually rebase when I commit to reorder the commit back to the top, and I push using HEAD^ to avoid pushing the local changes. I’ve also considered putting the changes in the stash, but that’s less convenient because it precludes normal use of the stash. Another alternative is to simply leave all those local changes unstaged, and use git add -p every time I want to commit. However, with a large number of trivial local changes, that becomes a hassle.
Here’s an example of my current workflow:
My repository initially looks like
A---B---C---F master
where “F” is my floating commit.
I make a commit:
A---B---C---F---D master
then git rebase -i HEAD~2 to reorder:
A---B---C---D---F master
then git push remote HEAD~1... to push everything but the local F commit.
The change F contains changes to existing versioned files, and may contain an arbitrary amount of changes. (If I can make more than one commit “floating”, that would be even better, since I could then separate my local changes).
How about putting those changes into a local branch which you rebase/merge regularly from your main dev branch? That way there wouldn’t be any danger of committing them upstream.