Sunday 14 August 2016

GIT SVN Notes

Commands

  • git svn rebase This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.
  • git svn dcommit Commit each diff from the current branch directly to the SVN repository, and then rebase or reset (depending on whether or not there is a diff between SVN and head). This will create a revision in SVN for each commit in Git.
  • git rebase -i HEAD~5 Squash multiple local commits into a single commit. Typically used before dcommit’ing to the svn repository.

Deleting directories from the repo.

It is recommended to add the following to your ~/.gitconfig when using git svn, otherwise locally deleted directories will not be removed in the repository.

[svn]
        # push empty directory removals back to svn as directory deletes
        rmdir = true

Handling Permission denied when rebasing:

If you get permission denied when rebasing (I've seen this in windows because my editor was locking files & directories), close any editors, explorer windows which are using files within the repository, Then:
  1. Take a backup of your repo/changes
  2. Abort the rebase: 'git rebase --abort' - Note that 'git svn' is not used for this command.
  3. Hard reset your checkout: 'git reset --hard ORIG_HEAD'
  4. Rerun your rebase as above.

Mounting an ISO/IMG on Linux / Raspberry PI

To mount an ISO/IMG file in Linux (or your Raspberry PI), first information on the contents of the image must be found using the fdisk command:

pi@pi_horizon_emb:~ $ fdisk  -lu /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img
 
Disk /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img: 1.3 GiB, 1361051648 bytes, 2658304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6f92008e
 
Device                                                   Boot  Start     End Sectors  Size Id Type
/media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img1        8192  131071  122880   60M  c W95 FAT32 (LBA)
/media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img2      131072 2658303 2527232  1.2G 83 Linux 

Note the block size and start location of the partition you wish to mount.
Then mount the partition within the image to a location of your choice on your local disk. Note you need to specify the offset, which is the start location * the block size.


pi@pi_horizon_emb:/ $ sudo mount -t auto -o loop,offset=$((131072*512))  /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img ~/iso_mount/
pi@pi_horizon_emb:/ $ ls ~/iso_mount/
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
pi@pi_horizon_emb:/ $

You can then modify the contents of the image partition. Note the partition size is restricted (it won't just expand as you add to it):


pi@pi_horizon_emb:/ $ df /home/pi/iso_mount
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/loop0       1210960 732164    399232  65% /home/pi/iso_mount

Monitoring Linux Disk Usage Using iotop

iotop

iotop needs to be run as root. Once running hit ‘a’, then ‘o’ - a will display accumulated I/O instead of bandwidth, and o will only display processes or threads actually doing I/O.
I’d recommend running it as ‘sudo iotop -d0.5’, this should get it refreshing its data at a reasonable rate.
E.g.
image2016-4-13 9:58:54.png

The only drawback of this mode, is that you won’t easily see results for processes which are periodically spawned and killed – you might catch them if you are continuously monitoring the output.
If you think you have processes which are periodically spawned and killed, you could try using it in batch mode: ‘sudo iotop -boat -qqq’, and pipe to grep to catch particular processes.

image2016-4-13 9:58:59.png