How to list all commits that changed a specific file?

The –follow works for a particular file git log –follow — filename Difference to other solutions given Note that other solutions include git log path (without the –follow). That approach is handy if you want to track e.g. changes in a directory, but stumbles when files were renamed (thus use –follow filename).

Remove specific commit

There are four ways of doing so: Clean way, reverting but keep in log the revert: git revert –strategy resolve <commit> Harsh way, remove altogether only the last commit: git reset –soft “HEAD^” Note: Avoid git reset –hard as it will also discard all changes in files since the last commit. If –soft does not … Read more

How can I push a specific commit to a remote, and not previous commits?

To push up through a given commit, you can write: git push <remotename> <commit SHA>:<remotebranchname> provided <remotebranchname> already exists on the remote. (If it doesn’t, you can use git push <remotename> <commit SHA>:refs/heads/<remotebranchname> to autocreate it.) If you want to push a commit without pushing previous commits, you should first use git rebase -i to … Read more

How to configure Git post commit hook

As mentioned in “Polling must die: triggering Jenkins builds from a git hook”, you can notify Jenkins of a new commit: With the latest Git plugin 1.1.14 (that I just release now), you can now do this more >easily by simply executing the following command: curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository> This will scan all … Read more

How can I revert multiple Git commits?

Expanding what I wrote in a comment The general rule is that you should not rewrite (change) history that you have published, because somebody might have based their work on it. If you rewrite (change) history, you would make problems with merging their changes and with updating for them. So the solution is to create … Read more

How to remove selected commit log entries from a Git repository while keeping their changes?

git-rebase(1) does exactly that. $ git rebase -i HEAD~5 git awsome-ness [git rebase –interactive] contains an example. Don’t use git-rebase on public (remote) commits. Make sure your working directory is clean (commit or stash your current changes). Run the above command. It launches your $EDITOR. Replace pick before C and D by squash. It will … Read more