git-diff to ignore ^M

GitHub suggests that you should make sure to only use \n as a newline character in git-handled repos. There’s an option to auto-convert: Of course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works … And then convert your files: core.autocrlf is described on the … Read more

How do I “un-revert” a reverted Git commit?

git cherry-pick <original commit sha>Will make a copy of the original commit, essentially re-applying the commit Reverting the revert will do the same thing, with a messier commit message:git revert <commit sha of the revert> Either of these ways will allow you to git push without overwriting history, because it creates a new commit after the revert.When … Read more

Git merge reports “Already up-to-date” though there is a difference

The message “Already up-to-date” means that all the changes from the branch you’re trying to merge have already been merged to the branch you’re currently on. More specifically it means that the branch you’re trying to merge is a parent of your current branch. Congratulations, that’s the easiest merge you’ll ever do. 🙂 Use gitk … Read more

Specify an SSH key for git push for a given domain

Even if the user and host are the same, they can still be distinguished in ~/.ssh/config. For example, if your configuration looks like this: Then you just use gitolite-as-alice and gitolite-as-bob instead of the hostname in your URL: Note You want to include the option IdentitiesOnly yes to prevent the use of default ids. Otherwise, … Read more

Resetting remote to a certain commit

Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do: However, you should avoid doing this if anyone else is working with your remote repository and has pulled your changes. In that case, it would be better to revert the commits that you don’t … Read more