Some useful commands for a Developer

Some useful commands for a Developer

If you want to add forgotten files into the previous commit git amend to the rescue:


git commit --amend –C HEAD

How to search files name from command shell


find . | grep nameoffileyouwanttofind

(You can use this for example when you want to migrate to another server and you need to move all your information in the database)

Export database


$ ssh youruser@server # you need to log in via ssh into your server
$ cat config/database.yml #see which is the database you are using
$ mysqldump -u root -h 127.0.0.1 database_name_to_export > exportfileinsql.sql

$ gzip -9 exportfileinsql.sql

After to export your database and download, now we are going to import our database in the new server

$ scp your_username@remotehost.com:exportsqlinfile.sql /somelocaldirectory/
$ gunzip exportfileinsql.sql.gz
$ mysql -u root -h 127.0.0.1 mydatabase_development < exportsqlinfile.sql

Using scp (Secure copy) in a different port or a non-standard one

// copying from local to remote a sql file
scp -P port_number local_file use@yourip:/yourdirectory/
// for example
scp -P 4225 project.sql use@yourip:/home/

If you are using postgress check the command

pg_dump

Print the value for a specific Enviroment variable (in this case RAILS_ENV)


$ echo $RAILS_ENV

No Comments

Post A Comment