Git: Ignore whitespace when merging or cherry-picking
You can tell git to ignore different kinds and amounts of whitespace when merging or cherry-picking. This often occurs when you changed indentation, or converted tabs to spaces.
Simply use
git merge <REV> -Xignore-space-change
or
git cherry-pick <REV> -Xignore-space-change
Geordi 1.2 released
Changes:
-
Remove some old binaries (commands still exist in
geordi
) and mark others as deprecated -
Rewrite deploy command to support most deploy scenarios:
- master to production
- feature branch to staging
- master to staging or production to production (plain deploy)
- Improve Cucumber command (fixes #18):
- Fix pass-through of unknown options to Cucumber
- Add --rerun=N option to rerun failed Cucumber tests up to N times. Reboots the test environment between runs, thus will pick up fixes you made durin...
Git: Keep your repository tidy
When you're using feature branches, they will stack up if you don't delete them after the merge to master
. Here's how to tidy them up.
Delete feature branches
Find already-merged branches by running
# On branch master
git branch --merged
You may safely delete each of the listed branches, because they point to commits that are contained in the history of your current branch (i.e. master
).
git branch -d my/feature-branch # Delete feature branch locally
git push origin :my/feature-branch # Push *nothi...
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
If you don't have add-apt-repository
yet, install it with:
sudo apt-get install python-software-properties software-properties-common
Git: Issues with Gemfile.lock
When there's a Gemfile.lock
in your working directory that you cannot remove by either checkout
, reset [--hard]
, stash
, probably Rails' Spring is the culprit and not Bundler itself.
Fix
spring stop
The author of the linked Stackoverflow post supposes Spring re-writes the Gemfile.lock
on change to ensure all Spring processes are using the same gem versions. Meh.
Instant Markdown previews from Vim
Live markdown previewer (with Github flavored syntax) for VIM.
Will open a preview in your browser and update automatically on each key press.
Ag: Very fast grep replacement
Ag
(aka "the silver searcher") is a very fast replacement for grep
.
It will parse your .gitignore
for additional speedup. To ignore even more files (node_modules
, *.min.js
etc), add an .ignore
with syntax identical to .gitignore
.
See Faster Grepping in Vim for hints about vim integration.
How to split up a git commit
Quick steps
-
git rebase -i
-> mark your commit withedit
-
git reset HEAD~
(remove the marked commit, but keep its changes) - Make several commits (optionally setting the previous author manually)
git rebase --continue
Detailed instructions
Basically, you will review the last n
commits and stop at the splittable commit. Then you'll undo that commit and put its changes into new commits at your liking.
-
Review commits (
rebase
)git rebase -i HEAD~3 # or git rebase -i origin/master
...
Recommended Git workflow for feature branches
This is a guide on how to effectively use Git when working on a feature branch. It is designed to get out of your way as much as possible while you work, and ensure you end up with clean commits in the end.
We assume you are the only person working on this branch. We also assume the branch has never been "partially" merged into master.
You want to start a feature branch
git checkout master
git checkout -b my-feature-branch
git push -u origin my-feature-branch
You've added code that works ind...
Flash-Free Clipboard for the Web
Unfortunately, Web APIs haven’t provided the functionality to copy text to the clipboard through JavaScript, which is why visiting GitHub with Flash disabled shows an ugly grey box where the button is supposed to be. Fortunately, we have a solution. The editor APIs provide document.execCommand as an entry point for executing editor commands. The "copy" and cut" commands have previously been disabled for web pages, but with Firefox 41, which is currently in Beta, and slated to move to release in mid-September, it is becoming available to Ja...
Using tig
tig
is a command line explorer for Git that is just awesome. Install via apt-get
or brew
.
Handy commands
-
t
("tree"): Directory-structure based access. You'll see the current directory annotated with the latest change date and its author. Navigate with arrow keys or vim. -
b
("blame"): Opens the file under the cursor and annotates each line with change date and author. -
d
("diff"): LikeENTER
on a commit, but arrow keys will scroll the diff! -
/
: Search current view (e.g. commit list, diff). Jump to next hit withn
....
Protip: Clone large projects multiple times
Large projects usually have large test suites that can run for a long time.
This can be annoying as running tests blocks you from picking up the next story -- but it doesn't have to be that way!
Simply clone your project's repo twice (or even more often).
When your work on a feature branch is done, simply push that branch and check it out on your 2nd copy to run tests there.
You can pick up a new story and work on that on your "main" project directory.
If you do it right, you will even be able to run tests in both your 2nd copy and your m...
Upgrading from Capistrano 2 to 3
Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest change is that they moved away from their custom DSL and use Rake
instead. For connecting with and operating on the servers, they bring a new gem SSHKit
which does the heavy lifting. It's SSHKit's DSL that is used anywhere inside the Rake tasks. See #Resources at the bottom for examples.
Step 1: Upgrade guide
For migration from 2 to 3, follow this tutorial: [Capistrano 3 Upgrade Guide](https://semaphorec...
Customizable date (and time) picker: Rome
Datetime picker that offers:
- simple UI without a specific framework
- several of customization options
- allows custom date/time validations
Localization happens via moment.js (which is a Dependency anyway).
However, you won't be happy trying to customize it too much:
- It does not support full custom templates, you can only set classes of its elements. If you require extra containers, you are out of luck.
- It offers only a few events, and you can not distinguish if users pick a date, switch to another month, or click outside of the p...
RubyMine: Scratch files
There are times when you have a chunk of text that you want to do something with, e.g. replace something on it, or quickly edit it.
While you can open your favorite non-RubyMine editor for this, there is also a plugin: Scratch.
It allows RubyMine to open temporary files (actually they are saved, but somewhere inside the plugin's directory) so you don't need to switch to a text editor like gEdit that works differently and may not even offer what you are used to.
Note that RubyMine also offers so...
Differences between transactions and locking
Web applications can be used by multiple users at the same time. A typical application server like Passenger has multiple worker processes for a single app. In a distributed deployment setup like we use at makandra you will even have multiple application servers, each with their own worker pool.
This means that your code needs to deal with concurrent data access. The two main tools we use to cope with concurrency are database transactions and distributed locks. These two are not interchangeable. You ca...
Getting permanent links to files on Github or Gitlab
Please don't simply copy line number links from Github. The URL usually contains a branch name like master
which will change over time:
https://github.com/makandra/upjs/blob/master/lib/assets/javascripts/up/link.js.coffee#L76
If someone now posts an insertion or deletion to that file into master
your link points to the wrong line!
A better way is to press the Y
key after clicking on a line number. This will transform the URL to another URL that points to the particular commit:
https://github.com/makandra/upjs/blob/b3b14...
Download Google Webfonts
An official Github repo by Google containing the binary font files served through Google Fonts, so you can easily download and install them locally.
Markdown Live Preview
An online markdown live previewer with GitHub Flavoured Markdown support.
Another online markdown live previewer with GitHub Flavoured Markdown support.
An online markdown live previewer without GitHub Flavoured Markdown support.
Did you know 'tig status' ?
It's like a GUI for the famous git add [-p]
.
Select files with the up/down-keys and hit
-
u
for staging/unstaging the whole file -
Enter
for showing the diff of a file-
j
andk
to navigate in the diff -
u
again to stage/unstage chunks -
1
to stage/unstage only lines -
\
to split large chunks
-
-
F5
to refresh the view
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 index
(i.e. amount of addition/deletions compared to the file’s size). For example,
-M90% means Git should consider a delete/add pair to be a rename if more than
90% of the file hasn’t changed. Without a % sign, the number is to be read as
a fraction, with a decimal point...
Preview Github-flavored Markdown from the bash with ianks/octodown
Preview what your markdown would look like on Github. Helpful e.g. when writing or extending a Readme for your gem or projects.
Installation
sudo apt-get install cmake libicu-dev # required for building native extensions
gem install octodown
Know that this will install at least 12 other gems. However, the beautiful output should be worth it.
Usage
octodown README.md
greckout - a bash script to grep and checkout your git branches
greckout query
This will list all branches matching your query as input options for git checkout
greckout ar
1) ar/cache-api-keys-1098
2) ar/add-categories-object-to-tv-show-1382
3) ...
SVGO: SVG Optimizer
SVG files are often much larger than necessary, containing comments, metadata, hidden elements etc.
Optimize them with this tool.
- Web UI: https://jakearchibald.github.io/svgomg/
- Binary: https://github.com/svg/svgo
Note that for a properly scaling SVG, you need to keep the viewBox
attribute. There's an option --disable=removeViewBox
for this.