Common CLI tasks

Published: Last updated:

In middle of the Agentic development processes, I have found that the mastery of the essentials CLI commands is even more crucial.

If we compare the efficiency of two scenario where two person knows how to prompt but one has mastered the CLI tools. Whenever the person needs the CLI command, they must prompt and wait for a response which breaks the workflow. The one who internalized the commands, will beat in time.

In this article, I will compile a list of the commonly used CLI commands in my workflow which can be fed to agentic to prefer over making up new ones.

Git

Create a new branch

git switch -c feature/TICKET-1 origin/main

Cherry Picking

# List the commit hashes from specific branch
git log --oneline HEAD..$BRANCH_NAME

# Cherry pick a range of commits from the branch
git cherry-pick $COMMIT_HASH_1^..$COMMIT_HASH_2

Rebase a branch

1. Fetch the origin

git switch feature/TICKET-1
git fetch origin
git rebase origin/main

2. Resolve the conflicts

Resolve the conflicts by editing the files that blocks the process.

## Stage the files when resolved
git add <file_path>
git rebase --continue

If something goes wrong, run the abort command

git rebase --abort

3. Push the branch

git push --force-with-lease origin HEAD

Drop commits

# Drop the latest commit
git reset --hard HEAD^

# Drop the last n commits
git reset --hard HEAD~n

Push a new branch

git push -u origin HEAD