Monday, October 1, 2018

Useful Git commands


To reset your master branch
git reset --hard origin/master
To remove directory
git clean -d -f
To know the repository url
git remote show origin
To remove unused branch from local
git remote prune origin prunes tracking branches not on the remote.
git branch --merged // lists branches that have been merged into the current branch.
xargs git branch -d //Deletes branches listed on standard input.
##Be careful deleting branches listed by git branch --merged. The list could include master or other branches you'd prefer not to delete.
To give yourself the opportunity to edit the list before deleting branches, you could do the following in one line:
git branch --merged >/tmp/merged-branches && vi /tmp/merged-branches && xargs git branch -d

Monday, July 9, 2018

Resolve Git bash Error: Could not fork child process: There are no available terminals (-1)


This can be a result of the GIt bash not been terminated properly in most of the cases node.exe is the culprit.
The solution would be to run the below command in cmd. taskkill /F /IM node.exe

Friday, January 19, 2018

How to kill a process listening to a port say "8080"


I have often encountered this issue while trying to run tomcat on port 8080. I get an error saying that the port is already being used by another process.
Below is the command that I used to kill that process:-
Step 1 : Find the process that is using this port.
netstat -ano | find "8080"
This command searches for the process listening to the port 8080.
Step 2 : Kill the process
I found that in my case the process with PID 22300 is listening to the 8080 port.
To kill this process use taskkill /PID 22300 /F

.htaccess display error pages on http errors

In your htaccess file add the below lines and save to show error pages on Http errors (404, 403 etc) ErrorDocument 403 /errors/404.html ...