Sometimes we need to find out which commits changed particualr file.

We can ontain this information using command git log with flag — follow:

git log --follow -- filename

This will list all the commits where this file was modified in the foramt of command git log.

--

--

Sometimes in working on your projects you need to undone some unwanted commits made to master branch. I will show how to do it with GitLab repo.

If you follow regular workflow with git reset to reset to some commit

git reset --hard <commit_hash>
git clean -f -d

and then force push to master to reflect changes on remote repo

git push -f origin main

you can get error

remote: GitLab: You are not allowed to force push code to a protected branch on this project.To gitlab.cleverbots.ru:cleverbots/hills_customer_care.git! [remote rejected] main -> main (pre-receive hook declined)error: failed to push some refs to 'gitlab.cleverbots.ru:cleverbots/hills_customer_care.git'

You need to obtain rights to force push to protected branch.

If you are maintainer go to Settings > Repository. Expand Protected branches, find master branch in list and move switch for option Allowed to force push

Thats it.

--

--

Sometimes we need to save some webpage. Standard way is to copy url and title (some main header) of webpage.

We can automate it and make our life easier. Use Copy page title and url extension for Chrome.

Just install it from Chrome store.

Then click right button on some page you need to save and choose option Copy page title and url marked by the icon of extension.

Both url and title will be copied to clipboard as one string.

--

--

Sometimes developers need to explore some JSON files. That can be quite tough and time comsuming. We can do it easier with command line tool jq.

First install it:

sudo apt updatesudo apt install -y jq

Run command:

jq '.' result.json

Result will be pretty nice looking

--

--