4

My question is, is there a way to mark a specific commit(s) so that either it won't be merged into another branch, or it will be ignored when I issue a "git push" or fetch from another repository?

My understanding is that you can cherry-pick specific commits to merge into the current branch; is there some way to mark a commit as 'local' to a specific machine/repository/branch?


The problem this question grew out of, I am currently solving a different way. Specifically, there is a specific version of sqlite3-ruby (1.2.5) that I require to work on a Rails application on one OSX machine to which I don't have root access. Right now I've made the commit to specify the version in the Gemfile on a local branch called "mac-bundle", and my plan is simply to switch to that branch and merge necessary changes before I run bundle if I need to install a ruby gem.

Which is a minor but live-withable annoyance. It seems possible that a similar situation might arise where the same workaround won't be quite as acceptable, so I thought I would ask for ideas on a different solution.

(Question similar to this one: Committing Machine Specific Configuration Files , and my current solution is similar to Greg Hewgill's answer.)

Community
  • 1
  • 1
Joseph
  • 539
  • 5
  • 13

2 Answers2

4

No, there is not a way to mark a commit as "not to be included in merges". Using separate branches is pretty much as close as it gets.

Amber
  • 507,862
  • 82
  • 626
  • 550
2

No, you can't. You can however "fake a commit" on a particular branch.

To do that, you can

git merge OtherBranchName --no-commit

This applies the changes and leaves it in the index for you to take action. Then, you can manually remove the changes applied and commit.

Git then thinks that commit has been applied on this branch, and you both live happily thereafter.

However, this might be ok as a one off, specifically to deal with configuration files. But you should not make this a general practice.

lprsd
  • 84,407
  • 47
  • 135
  • 168
  • That seems pretty close in effect to what I was asking for, but it definitely feels like something that could cause weird problems later. Thanks for the suggestion, though! – Joseph Jan 27 '11 at 17:47