git: How to forget a recorded resolution
If you recorded Show archive.org snapshot a bad fix for a conflict, you can tell git to forget that bad resolution:
git rerere forget your_file.rb
Afterwards, the badly resolved file will still be in your working directory. To get it back with confict markers, say:
git checkout -m your_file.rb
Resolve the conflict again, properly now. ;)
Related cards:
How to mirror a git repo to a new remote
Say you want to move a git repository from one remote (perhaps Github) to another (perhaps Gitlab).
If you have the repo checked out, you still should make sure to mirror all branches of the old remote, not only those you happen to have checked o...
Creating a patch in git and how to apply patches
You can convert git commits into patch files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via e-mail).
Creating a patch in git
- Make your changes and commit the...
How to install a current version of git to your Ubuntu machine
As described by the linked Stackoverflow answer, run these commands:
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git
git --version
This will get you Git 2.6.4 (as of Dec 2015).
Troubleshooting...
Git: How to get a useful diff when renaming files
tldr; Use git diff -M
or git diff --find-renames
when you've moved a few files around.
Usage
$ git diff --help
Options:
-M[<n>], --find-renames[=<n>]
Detect renames. If n is specified, it is a threshold on the similarity ...
Git: How to add changes matching a regular expression
When you have many changes, and you want to spread them across different commits, here is a way to stage all changes matching a given regular expression for a single commit.
Example
Consider the following git diff
output.
diff --gi...
Capistrano 3: How to deploy when a firewall blocks your git repo
Sometimes, through some firewall or proxy misconfiguration, you might have to deploy to a server that cannot access the git repository.
Solution 1: HTTP Proxy (this is the preferred fix)
SSH can be tunneled over an HTTP Proxy. For example, wh...
Git: How to stash with a custom message
If you say git stash
, your stashed changes will be identified with an automatically generated message:
$ git stash
Saved working directory and index state WIP on master: 77af0df Merge branch 'production'
While this is okay to temporari...
Git: How to stage hunks with a single key press
In interactive commands, Git allows the user to provide one-letter input with a single key without hitting enter (docs).
# Enabled this feature global...
Git: How to show only filenames for a diff
When you want to do a git diff
but do not care about the full diff and just want to know which files changed, use the --name-only
switch:
$ git diff --name-only
app/controllers/sessions_controller.rb
app/models/user.rb
feature...
How to undo a 'git reset --hard'
So you erased a whole day's work? There is hope! The linked article tells how to recover from an accidental git reset --hard
.
On a Mac
You will need to install GNU find utils as described in [this SO post](http://stackoverflow.com/a/1405664/3...