Rename your local foo
branch with bar
:
git branch -m foo bar
Remember this will add the new branch with you push
, but it won’t delete the old foo
remote branch.
Add -f --mirror
to rename the branch on the remote:
If you are accustomed (like me) to fire Ctrl+R
before running any new command, here is a tip to keep your Shell history clean and more search-friendly.
The best way to do this is to prevent some commands (e.g. those with passwords inlined) to be logged, but also to skip saving duplicated commands.
This is all controlled by the environment variable HISTCONTROL
. It can take 3 values:
ignorespace
: lines which begin with a space character are not savedignoredups
: lines matching the previous history entry are not savedignoreboth
: is shorthand for ignorespace and ignoredupsThe use case is simple, you have /reports/593874951.pdf
on your web server and want to let your user download it — and if possible with a meaningful name.
In the past, you may tried using the Content-Disposition
HTTP header to achieve this, but today, with Safari getting the support for the download
attribute it’s going to simplify a lot of things.
Using the download
attribute is simple as pie:
<a href="/reports/593874951.pdf" download="report.pdf">
Download report
So you hit "Fork" and now you have this repo copy on your Github account. Here is what to do to keep it up-to-date with the original repo.
1. Add the original repo as remote, here called upstream:
git remote add upstream https://github.com/author/repo.git
2. Fetch all the branches of that upstream remote:
You may want to upload a 100GB file over an unstable network, or feed your scripts smaller inputs to load in RAM. In both cases, just splitting your file into smaller chunks is an easy solution.
Great news is Unix/Linux systems have the split
utility already installed. And using it is simple as pie:
Cut a binary file into chunks of X bytes:
split -b X bigfile.avi
Following on our CSV file processing series, here is how to count the number of lines that match a condition.
We’ll keep using awk
. Here is the command to run on the records.csv
file:
awk -F, '{if ($5 == "foo") count+=1} END {print count}' records.csv
When you only have a few thousand lines, a spreadsheet software will do. But when you got millions, it’s another job.
Unix has the awk
command, which you might not use too often, if at all, but is both powerful and easy get started with.
See here how to sump up all numbers in the 3rd column in records.csv
:
awk -F',' '{sum+=$3} END {print sum}' records.csv