The Daily Git commands

I always keep googling for few of the git commands that I use on a small interval ( not very frequent ) and end up spending more time then I should be. So instead I’ve compiled a list of Git commands that are helpful in my project development, which might be useful for you as well. I’ll keep updating the list as and when I find something useful.

Clone a git repo ( or Checkout in terms of SVN ):

If it’s a private repo, you need to have your SSH keys added on server ( Github, Bitbucket or GitLab ) or you can use the https url to clone with your login details, for a public repo you need not to have SSH keys or login details, after that you can easily clone a git repo.

Navigate to a folder under which you want to clone the repo, and run the command.

Using SSH (If public keys have been added to server)

git clone [email protected]:UmeshSingla/user-tags.git

Using https

git clone https://github.com/UmeshSingla/user-tags.git

Deleting a remote Git Branch:

git push origin –delete branchName

Delete a remote Tag:

git push origin :tagname

After deleting tag remotely, you need to delete the tag locally as well, otherwise you won’t be able to the re-create the tag

Delete a Tag Locally:

git tag -d tagname

Delete a Folder from git repo:

This will delete the folder only from git repo:

git rm -r --cached folderName

In order to Delete the folder from filesystem and git repo:

git rm -r folderName

If you are getting any warnings you can use ‘f’ for force delete:

git rm -rf folderName

How I fixed my blunder with Node – Mysql DB performance

Thanks to the circumstances, where I was left with no option other than to complete the node script, I was able to learn a bit of node.

Initially for the node script we opted for SQLite, considering it is lite and it’ll serve the basic purpose to handle the read and writes we required, a good db performance. But as the no. of concurrent users increased, it totally blew up. My node script stopped responding as it was waiting for database all the time.

What I concluded: Sqlite uses file for storing database, and each time I was making a read or write it locks the whole db slowing down the whole db performance. Thanks to one of my teammate Aaron, he suggested to switch to MySql.

And it seemed to work much better then sqlite, script was running without being choked for multiple simultaneous users.

But the happiness wasn’t long term, because I’m a newbie 😛 when it comes to database administration. As the database size increased it started slowing down again as I haven’t implemented table indexes, and I was relying only on my Primary Key for all SELECT queries.

As a result a single SELECT query would take upto 9s, 20s and so on. So I added indexes for all columns which were used in WHERE clause, but beware, more the number of indexes you use, more it’ll slow down inserts, as mysql updates the whole index after each query.

This kind of sorted out a whole lot of performance issues.

This is where I made a big mistake: Performance issue was resolved upto a big extent, but then I started facing trouble with some particular file names having special characters É, Ã as I was using a character set other then `utf8_unicode_ci`.  I added the ALTER table query to the script and boom another problem solved. Happy Faces all around 🙂

Later on I increased the buffer pool size after reading about it on http://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size

And the last issue, after my db size grew over 1Gb, whenever I restarted my node request handler script, it’d take atleast 20 minutes, yeah minutes not seconds before mysql would start responding and I had to think before pushing changes, as it’d result in server downtime for that long. And it was all just because I was too careless or a noob :), to leave the Alter table query in the script, yeah.

So everytime I restart the script the whole 2Gb table would be modified, taking half an hour or more, and it’ll keep the tables lock for all that period, resulting into non responding server. And removing those queries solved the whole slowing down on node server restart.

Right now, I’m bit relaxed, unless I encounter another mistake of my own 😉

About Mysqlite,  I think if I have used indexes in sqlite, it would have been scalable enough.

If you are encountering any such issues, you can always check MySql slow query log or if you are using PHPMyAdmin, you can always check the current query being executed and if it is holding the lock over the table, blocking other queries or you can simply login to your mysql console and run the query SHOW FULL PROCESSLIST\G 

Checking the slow queries in PMA
Checking the slow queries in PMA

For updated PMA:

Checking current process list

If you have any other method to tune Mysql database for performance, drop it in comments, I’d love to hear it.

I’m already planning to implement Table compression and partitioning, after I read them thoroughly.