Git Command

Git Command

posted 1 min read

The Clean All (discard all changes)

git clean -fd

How do you move a commit to the staging area in git?

git reset --soft HEAD~1

Pushing empty commits to remote

git commit --allow-empty -m "Trigger Build"

History

git log --graph --color --decorate --oneline --all
gitk --all

Git to discard uncommitted changes in your working directory

git restore .

Moves the last commit back to the staging area (index), keeping all changes.

git reset --soft HEAD~

Moves the last commit back to the staging area (index), Discard all changes.

git reset --hard HEAD~

Deletes a local branch named branch_name.

git branch -d branch_name

Force Delete a Branch (If Not Merged):

git branch -D branch_name

Delete a Remote Branch:

git push origin --delete branch_name

List both local & remote branches:

git branch -a

Prunes (removes) local references to remote branches that no longer exist on the remote.

git fetch --prune

Quickly Switch to the Previous Branch

git checkout -

Show a Visual Branch Tree

git log --oneline --graph --all

Search Commit Messages

git log --grep="bugfix"

Configures Git to use Windows' built-in SSL/TLS (Schannel) instead of OpenSSL

git config --global https.sslBackend schannel

Trigger the CI/CD pipeline with a blank commit

git commit --allow-empty -m 'Empty commit'

visualizing Git history

gitk

How do you move a commit to the staging area in git?

git reset --soft HEAD~1

Git to discard uncommitted changes in your working directory

git restore .

source:- link

More Posts

Learn Git fast as if your job depends on it

Nikola Breznjak - Feb 16

The Renaissance of Git Worktrees

Mark Kazakov - Apr 30

GitWand - A complete workflow for GIT

devlint - Apr 21

Why I built another Git client

devlint - Apr 21

Git Worktrees Are Underrated

morellodev - Mar 17
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!