Git - Remove Tracking Branches that are no longer on remote

The remote tracking branches may still exist in your local after a feature branch is merged(to a main branch) and deleted from remote (the normal pull request workflow) The corresponding local branches too may exist and pile up locally, if you are too lazy to delete them. Is there a way to use the information available on remote (say only main branch exists on remote (the longest living branch.)) -...

June 28, 2022 · 2 min · Anant

Some cool Git Shortcuts

git commit -am “message” git commit -am "message Adds all the files in current working directory Alias git config --global alias.ac "commit -am" # How to use it: > git ac "message" Reword the last commit message git commit --amend -m "new message" Also useful when you forgot to include or stage a couple of files with last commit. git commit --amend --no-edit #if want no change in prev commit message This only works until before you havent alreday pushed your code to a remote repo....

May 28, 2022 · 3 min · Anant

GitHub Contribution not counted!

My email ID (with gmail) contains. . Like ab.cd@gmail.com. Usually with Google/gmail it is not a problem - login etc work as usual if I skip the . ab.cd@gmail.com abcd@gmail.com On Gmail, both are equivalemt. Login works with both, as Google ignores dots in Gmail addresses. But for GitHub it is not the case. I had GH setup with ab.cd@gmail.com I was using commit email without the dot, i.e. git config user....

April 26, 2022 · 1 min · Anant

Bash Script to switch Git Configs

I have following global git configs: git config commit.gpgsign # true for work, false for personal git config user.name # different for work(global) and personal git config user.email # different for work(global) and personal Assuming the default(global) git config is my work related configs, which I dont want to use for personal git repos So I can switch to personal every time I work on a personal project. To change all the 3 with predetermined values, use following shell script....

April 22, 2022 · 2 min · Anant

Renaming remote git repo

If you had a local repo and a remote repo connected to it (say on GitHub) - and for some reason you decide to change the repo name on remote, what do you need to do locally to keep things working? (as push/fetch/pull from local start to fail due to rename) Rename the remote repo(1,2), and then tweak the local repo(3,4,5) so that things work as expected: Go to the remote host (for example, https://github....

April 22, 2022 · 2 min · Anant