Skip to main content

GIT : God's way of semantic versioning

· 2 min read

Here are some of the GIT hacks everyone should know of

1. GitLens

GitLens is a VSCode extension. This has been a lifesaver for me and my team. It works beautifully with vs code. I can compare commits, and code from different branches, check current blame by just hovering, manage stashes, check blame, heatmap, file changes, push & pull code, etc with so much ease.

2. Moving or Migrating stashes from old computer to new.

  • First, List all your stashes.
git stash list
  • Second, Export to Patch files. You'll have to specify your stash ID and provide a name for your patch file. Do this for all the stashes you want to move.
# stash@{0} is your stash id which is printed with above command, copy and paste below
git stash show -p stash@{0} > stash-name-0
git stash show -p stash@{1} > stash-name-1
  • Patch files will be created in the current directory. Copy the patch file into the new directory on the new machine.
  • Finally, Apply your stashes and finally Re-Stash them
cd /new/project/dir
git apply stash-name-0
git stash
git apply stash-name-1
git stash

3. Delete branch on local and remote

# to delete branch on local repo
git branch -d <branch-name>

# to push delete branch on remote after deleting on local
git push origin -d <branch-name>

4. Stage all files and commit in one line

git commit -am "add all and commit"