This week of Things I learned, I would like to write about some git commands. These commands are parts of my daily usage. I would end up googling them every time they needed and go through a lot a links until land on the correct result. To save time I have gathered them at one place.
- Remove Git branch locally and remotely
- Configure Git username and email
- Look for dependency in a project or npm search dependency tree
Remove Git branch locally and remotely
The excerpt for this Stack overflow link is as follows
Git command to configure user name and email
When you create a new git project and push it to github, the global user name and email is picked up. If you haven’t configure them globally you can test them by running following command in the terminal.
If no name or email is configure than we have a dummy gravatar icon on git hosting platforms i-e github, gitlab. When you set you email either globally or locally ( repsitory specific) the avatar is picked from gravatar.com.
There is one more use case to setup local git configurations. For example at work I have different global user and email. When I work on personal toy project and push commits, the are pushed with my office identity i-e global configs. May be I want the commits to be tracked by different user. In that case the only solution to setup repository specific configuration using following git commands. Excerpt taken from atlassian article.
NPM Search dependency tree
The urgency to search through your
node_modules for certain npm project is when github alerts us about potential security vulnerability
In our case I had to search for minimist dependency. I haven’t used it directly. May be one of my dependency have used or may be dep of dep have used. One can imagine the nested hierarchy here. So npm command to help in such condition is
For me I got following result.
Now updating firebase might fix it. (I think github can also auto fix by creating a pull request).
Git Discard unstaged changes
Visual Studio has this nice feature to discard changes. You can doddle around and just discard all the changes you made. Especially when you don’t want to use stash
Yet another stackoverflow answer for the r.escue This time I extracted the following git command which helps in my case.
git checkout -- .