Image for post
Image for post

In this post let’s see different ways of resetting a file to a particular revision.

Using checkout

git checkout <commit_hash_id> -- <file_path> Example 
git checkout cc1d4a7 -- example.py

I think the above command is very self-explanatory.

You are reverting a file to a particular commit. In other words, git will take the mentioned file and apply the mentioned commit changes to it.

You can mention multiple files to revert too.

git checkout cc1d4a7 -- example.py index.py

Using restore

git restore --source <commit_hash_id> <file_path> Example
git restore --source cc1d4a7 index.py

We have seen restore in our previous edition. …


Image for post
Image for post

Github CLI is one of the useful tools you can start using right away if you are a very active Github user.

You can visit the repo here.

This is still in beta but you can still use it. It brings PRs, issues, and other useful features of Github to the command line.

I will cover some commands that I find very useful. And you can also play around with the tool.

Listing Pull requests

You can list all the PRs of the repo.

There are options for filtering PRs with the assignee, base branch, labels.

Examples:

gh pr list --label "WIP, help" // List PRs with the provided…


Image for post
Image for post
Forgit — Lightweight CLI tool

Forgit is a lightweight CLI tool that helps you to use Git interactively. This tool is a very useful tool that helps you to work effectively.

Installation

This tool uses fzf. So don't forget to download it.

To install fzf, follow these instructions for your respective platforms.

To install Forgit,

Usage

Some of the useful commands in Forgit

git add

The default command is ga

Image for post
Image for post

In the above image, you can see the interactive screen.

You can use arrow keys to navigate up and down.

git log

The default command is glo

Image for post
Image for post

As the tool uses fzf, you can fuzzy search the logs.

git stash

The default command is…

About

Srebalaji Thirumalai

Made in India, Programmer, Indie Hacker, Love Rails and React. srebalaji.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store