Using Git bisect to find out when a bug was introduced!

—-Simplified explanation—-
Here’s how to use git bisect , step-by-step!
Step 1: Find a commit where things were working. …
Step 2: Find a commit where things are not working. …
Step 3 – N: Use git bisect to find the problem commit. …
Step 4: Get back to a working state.
Using Git bisect to figure out when brokenness was introduced

Step by step with code.

git log -4 # find previous working commit
git checkout #hash
git bisect ?

run through previous commits then

git bisect good or bad
git checkout #hash

See link to get more info and better understanding.

How to ignore files only locally in git?

I have automated tests running everyday, and the issue is that those tests make necessary changes to certain files depending on which test is running. This becomes a problem when I have to report the changes in the repo, as this will report untracked changed, which means I have to ignore certain files such that local Git doesn’t report changes in them specifically.

By making sure to run git update-index --assume-unchanged ./matplotlibrc after making the addition to the exclude file this means changes won’t be picked up until then.


git update-index --assume-unchanged index.rst
git update-index --assume-unchanged matplotlibrc

Before:
Screenshot_2017-06-02_07-31-01

After:

Screenshot_2017-06-02_08-19-20.png

Changes made but untracked, nice!!!

How can I merge two or more Git commits into one[locally and remote]?

You can do this fairly easily without git rebase or git merge --squash. In this example, we’ll squash the last 3 commits.

If you want to write the new commit message from scratch, this suffices:

git reset --soft HEAD~3 &&
git commit

If you want to start editing the new commit message with a concatenation of the existing commit messages (i.e. similar to what a pick/squash/squash/…/squash git rebase -i instruction list would start you with), then you need to extract those messages and pass them to git commit:

git reset --soft HEAD~3 && 
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"

Both of those methods squash the last three commits into a single new commit in the same way. The soft reset just re-points HEAD to the last commit that you do not want to squash. Neither the index nor the working tree are touched by the soft reset, leaving the index in the desired state for your new commit (i.e. it already has all the changes from the commits that you are about to “throw away”).

Important: If you’ve already pushed commits to GitHub, and then squash them locally, you will have to force the push to your branch.

$ git push origin branch-name --force

Helpful hint: You can always edit your last commit message, before pushing, by using:

$ git commit --amend

Credit

Diagnosing LAN Speeds

After having network issues/degradation while trying to access a work server, I had to diagnose the network the server is connected to. I had to set myself on a mission – and after realising that the seems to be very limited tools for such things, I stumbled upon ‘iperf‘.

Iperf is a command-line tool used in the diagnostics of network speed issues, it measures the maximum network throughput a server can handle. It is particularly useful when experiencing network speed issues, as you can use Iperf to determine which server is unable to reach maximum throughput.

Iperf installation

Iperf must be installed on both computers you are testing the connection between.

sudo apt-get install -y iperf

TCP Clients & Servers

Iperf requires two systems because one system must act as a server, while the other acts as a client. The client connects to the server you’re testing the speed of.

  1. On the node you wish to test, launch Iperf in server mode:
iperf -s

You should see output similar to:

Screenshot_2017-05-05_12-02-15

2. On your second Linode, connect to the first. Replace dbelab04 with the first node’s IP address in my case i’m using the hostname

iperf -c dbelab04

You should see output similar to:
Screenshot_2017-05-05_12-02-53

3. You will also see the connection and results on your Iperf server. This will look similar to:

Screenshot_2017-05-05_12-03-04

4. To stop the Iperf server process, press CTRL + c.

————————————————————————————————–

You can do pretty much the same thing with plain old nc (netcat) if you’re that way inclined. On the server machine:

nc -vvlnp 12345 >/dev/null

You should see something similar to:

Screenshot_2017-05-05_12-14-05

And the client can pipe a 10Gb of zeros through dd over the nc tunnel.

dd if=/dev/zero bs=10M count=1K status=progress | nc -vvn 192.168.4.23 12345

You should see something similar to:

Screenshot_2017-05-05_12-13-54

The timing there is given by dd but it should be accurate enough as it can only output as fast the pipe will take it. If you’re unhappy with that you could wrap the whole thing up in a time call.

Remember that the result is in megabytes so multiply it by 8 to get a megabits-per-second speed. The demo above is running at 11.8mbps due to my laptops network limitation and number of hops…