Question

I use git to manage my dotfiles, I use both linux and mac osx so I create separate branches for these two and another master for the common settings.

When I edit something which is common and I want to save the changes to another branch. This is how I work at the moment:

git checkout master
git commit ...
git checkout arch
git checkout master <file1>
git checkout master <file2>

This is a lot of work. Can I checkout a commit instead of file, or is there any even shorter way than this ?

Was it helpful?

Solution

Instead of cherry-picking (see its disadvantage here), I would rather merge master in the other branches.

See for instance "Git branches for working on dev while merging some changes into the master".
That way, you know what was already integrated into your branches from master.

OTHER TIPS

You can do git cherry-pick <changeset hash>. E.g. git cherry-pick 1a15f41e2. This will apply the commit to current branch. If the commit exists only in remote repo you will have to do git fetch before cherry picking. Documentation: http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top