How to cherry-pick multiple commits

Git 1.7.2 introduced the ability to cherry pick a range of commits. From the release notes: git cherry-pick learned to pick a range of commits (e.g. cherry-pick A..B and cherry-pick –stdin), so did git revert; these do not support the nicer sequencing control rebase [-i] has, though. To cherry-pick all the commits from commit A to commit B (where A is older than B), run: If you want to ignore A itself, … Read more

Getting key with maximum value in dictionary?

You can use operator.itemgetter for that: And instead of building a new list in memory use stats.iteritems(). The key parameter to the max() function is a function that computes a key that is used to determine how to rank items. Please note that if you were to have another key-value pair ‘d’: 3000 that this method will only return one of the two even though they … Read more

How can I git stash a specific file?

EDIT: Since git 2.13, there is a command to save a specific path to the stash: git stash push <path>. For example: OLD ANSWER: You can do that using git stash –patch (or git stash -p) — you’ll enter interactive mode where you’ll be presented with each hunk that was changed. Use n to skip the files that you don’t want to … Read more