Category: TIPS

Git Hacks

Whenever you do git pull and you find some files modified locally as part of build and want to overwrite it with the contents in the git repository.

git checkout HEAD^ file/to/overwrite
git pull

To checkout a new git branch and to create a new git branch and checkout

git checkout <branch>

git checkout -b <branch>

To delete a remote branch and local branch

git push –delete origin bugfix/
git branch -d bugfix/

To copy a directory without its history and add as a new folder in git

cp -R old_dir new_dir

git add new_dir

git commit -m "first revision of new_dir's copied files"

Creating a diff file

git diff > 1.patch

Applying a git generated patch file

git apply 1.patch

Saving your changes while checking out a branch

git stash save

if you have to save again

git stash save

stash@{1} – older changes…newest will become stash{0}

git stash list – lists all stash

git stash drop

stash@{0} dropped. stash@{1} will become stash@{0}

git stash apply stash@{2} – to apply changelist in stash{2}

git stash drop stash@{2} – to drop the changelist in stash{2}

git stash pop - To get everything back
git checkout -b newbranch
git stash pop


git stash pop - Restore back to the saved state, but it deletes the stash from the temporary storage.
git stash apply - Restore back to the saved state and leaves the stash list for possible later reuse. Need to use below command to drop them.
git stash drop

git stash apply 1 is equal to git stash@{1} apply

To rename a git local branch

Use -m option to rename a branch. Here I forgot to add bugfix/ prefix int he branch name. So -m command helped me to add it.
git checkout bugfix-branch
git branch -m bugfix/bugfix-branch

To cherry pick a pull request

Create a new branch form the origin branch where you want to add the fix.

git branch cherry-branch origin/master

switch to the new branch

git checkout cherry-branch

Cheery pick the commit using commit id.

Use git log to find the commit id.

git cherry-pick COMMIT-ID

Push the new branch to your fork

git push origin cherry-branch

  • References
  • http://blog.asquareb.com/blog/2014/06/19/making-a-git-pull-request-for-specific-commits/

To Backport changes

To fetch all upstream changes
git fetch –all

create the cherrypick branch from the branch intended to check-in

git branch my_cherrypick_branch rel/release_branch_to_checkin

checkout temporary cherry pick branch

git checkout my_cherrypick_branch

cherry pick the commit

git cherry-pick dc4264056167c7ef9d496b276e9f2699d1b91106

push the cherry pick branch to upstream.

git push –set-upstream origin my_cherrypick_branch

Now create the pull requests.

to download again the artifact

git lfs uninstall

git pull

git lfs install

git lfs checkout

The different engineering validation stages in a nutshell | EVT, DVT, PVT

Hardware development comes in different phases. This article gives a nutshell of each phase.

PRD(Product Requirement Document)
PRD will allow the engineers to start doing the work on the hardware and mechanical level. You might end up with a mock up in order to see a non-functional design but the game is to reach something that some beta users can manipulate and that we could call MVP (Minimum Viable Product).

EVT (Engineering Validation and Testing)
Once your hardware is finalised, it needs to be tested and validated. This step is called EVT. The product cannot pass EVT if not all functional requirements are matched and if the hardware is providing the results and metrics that were expecting in the PRD through the specifications for example. Hardware and it will be tested for thermal, power, and EMI stresses.

DVT (Design Validation and testing)
The hardware will be produced in a small lot and will go through thorough test like dropping it from a certain height, burning it, check if it is waterproof, etc. Every country has different certifications and standards for products.

PVT (Production Validation and Testing)
This stage DFM (Design For Manufacturing) has been done and the moulds are ready, so is the stencil for your PCB (printed Circuit Board) by setting up a production line.This stage also consists DFA (Design For Assembly) as it can happen at different stages but most probably close to the end and it will allow engineers find the best and most efficient way to assemble the product after getting produced.

Source: The different engineering validation stages in a nutshell | EVT, DVT, PVT

How to Disable Disk Write Caching in Ubuntu To Prevent Data Loss | UbuntuHandbook

Disk write cache is a feature provided by drive vendors to improve the performance of the disks.
This feature can result in data loss if there are sudden power outages.
It depends on the application to decide whether to enable disk write cache or not.
For SATA SSD drives the following commands can be used to enable and disable write caching.

To know write caching is enabled/disabled
hdparm -W /dev/sda

To enable write cache
hdparm -W 1 /dev/sda

To disable write cache
hdparm -W 0 /dev/sda

where, /dev/sda is example SATA SSD used.

You can get the details of the drive susing lsscsi command.

Source: How to Disable Disk Write Caching in Ubuntu To Prevent Data Loss | UbuntuHandbook