Tuesday, October 16, 2018


GIT Command 1. Initialize git repository type command in the terminal: $ git init $ git add --all $ git commit -m "Initial Commit" 2. Create a new repository. Login into git repository
3. Locate git clone url
         e.g.   https://username@your..domain:7999 /yourproject/repo.git

4. Push the files to repository
        type command in the terminal: $ git remote add origin https ://username@yourname.domain:7999/yourproject/repo.git $ git push -u origin master 5. Error - failed to push some refs to 'https://username@bitbucket.org/yourname/yourproject/repo.git

       type command 

$ git pull --rebase origin master
$ git push origin master

hat way, you would replay (the --rebase part) your local commits on top of the newly updated origin/master (or origin/yourBranch: git pull origin yourBranch).
--------------------------------------------------------------------------------------------------------------

1.    Getting Help

Three ways to get the manual page (manpage) help for any of the Git commands

$ git help <verb>
$ git <verb> --help
$ man git <verb>
           e.g.  $ git help config
2.    Check Your Git Settings
$ git config –-list 3. 


a.     Check user name
To get user name for a specific repository 


$ git config user.name Or   $ git config --get user.name
Nitin 
To get user name for all repositories
$ git config --global user.name Or   $ git config --global --get user.name
Nitin
b.    Check user email
To get user email address for a specific repository
$ git config user.email Or   $ git config --get user.email
nitink@cdac.in
To get user email address for all repositories
$ git config --global user.email Or   $ git config --global --get user.emailnitink@cdac.in
3. Your Identity 
Set user name & email address. This is important because every Git commit uses this information
 To set user name for a specific repository
a.     $ git config user.name “Nitin Karale” 
To set username for every repository  
a.     $ git config --global user.name “Nitin Karale”
b.    $ git config –global user.email nitin.tkarale@gmail.com
4. Check remote url        To get remote url of repository $ git config --get remote.origin.urlhttps://nitin_karale@bitbucket.org/nitin_karale/sorghum.git

$ git remote show origin
* remote origin
       Fetch URL: https://username@domain/yourname/repo.git
 Push  URL: https://username@bitbucket.org/yourname/repo.git
 HEAD branch: master
 Remote branches:
    SorghumV1                tracked
    SorghumV2                tracked
    google-play-services_lib tracked
    master                   tracked
    sorghum-android-studioV2 tracked
 Local branch configured for 'git pull':
    SorghumV2 merges with remote SorghumV2
 Local refs configured for 'git push':
    SorghumV2                pushes to SorghumV2                (up to date)
    sorghum-android-studioV2 pushes to sorghum-android-studioV2 (up to date)


5.  Set remote url in initialize
a)    Initialize git first
$ git init
It shows initialize git
b)    Check remote url by using following command
$ git remote –v
origin  https://username@domain/yourname/repo.git (fetch)
origin  https://username@domain/yourname/repo.git (push)

If it is empty then use commandE.g. $ git remote add origin {repository-url}

6.    Make sure you have not set the GIT_COMMITTER_NAME or GIT_AUTHOR_NAME variables. You can check their values with the following command:
a.     $ echo $GIT_COMMITTER_NAME
         # prints the value of GIT_COMMITTER_NAME
Output - It’s NULL (if not set value)
b.    $ echo $GIT_AUTHOR_NAME
   # prints the value of GIT_COMMITTER_NAME
Output - It’s NULL (if not set value)

Set committer name & author name
a.     $ GIT_COMMITTER_NAME=Nitin Karale

b.     $ GIT_AUTHOR_NAME=Nitin Karale


7. Unstage an added file in Git. If you added a file by mistake, you can unstage it (but keep local changes) by saying

   $ git reset HEAD path/to/file        This is also what  $ git status will tell you

8.    Merging
After pull it will get merging
HCDC-PC8+Nitin@HCDC-PC8 MINGW64 /e/NVLI/automated-classification-tool (dev|MERGING)
Then use following command
$ git commit
     It shows git commit then use :q command

9.    Clone specific branch
                $ git clone –b {specific branch} {repository url}
      e.g
$ git clone –b dev {remote url}
10.    Shows remote branches & local branches
$ git branch
* master
$ git branch -a
* master
  origin/1-2-stable
  origin/2-0-stable
  origin/2-1-stable
  origin/2-2-stable
  origin/3-0-unstable
  origin/HEAD
   origin/master
$ git branch -r
  origin/1-2-stable
  origin/2-0-stable
  origin/2-1-stable
  origin/2-2-stable
  origin/3-0-unstable
  origin/HEAD
  origin/master
11.    Remove local untracked files from the current Git branch
a)     If you want to see which files will be deleted you can use the -n option before you run the actual command:
     $ git clean –n
 E.g.
  $ git clean -n
 Would remove src/main/webapp/WEB-INF/glassfish-resources.xml

b)     Then when you are comfortable (because it will delete the files for real!) use the -f option:
$ git clean –f
c)     Here are some more options for you to delete directories, files, ignored and non-ignored files
·       To remove directories, run
$ git clean –f -d or $ git clean –fd
·       To remove ignored files, run
$ git clean –f -X or $ git clean –fX
·       To remove ignored and non-ignored files, run
$ git clean –f -x or $ git clean –fx
12.    Stash - To record the current state of the working directory
      a) To record the current state of the working directory and the index, but want to go back to a clean working directory 
                        $ git stash 
b)    To show list of stash
       $ git stash list 
stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
stash@{1}: On master: 9cc0589... Add git-stash 
Or
                    $ git stash show 
Update git-stash documentation
Add git-stash 
c)     To pop stash
Remove a single stashed state from the stash list and apply it on top of the current working tree state
                        $ git stash pop

d)    To “Apply” Like pop, but do not remove the state from the stash list

     $ git stash apply stash@{0}

e)    “Clear” - Remove all the stash entries. Note that those entries will then be subject to pruning, and may be impossible to recover
               $ git stash clear
13.   Git ignore file 
       .gitignore  Remove ignores files which are tracked before git add

            a) Create a .gitignore file in project root

             b) Edit .gitignore file in notepad
             c) write all the files line by line you don´t want to add on the repository
               e.g.   
                      
           d)Then in your git bash you have to write the following line:
                             
                             $ git config --global core.excludesfile ~/.gitignore_global

             e) Commit all files 
                    
                            $ git rm -r --cached .

                            $ git add .
                                   $ git commit -m ".gitignore is now working"

Wednesday, July 11, 2018

Linux Command

#To find process by port

root@My-ThinkPad $ sudo lsof -i :5672 | grep LISTEN  
[sudo] password for root: 
beam.smp 953 rabbitmq   52u  IPv6 33026      0t0  TCP *:amqp (LISTEN)

Kill process  

sudo kill 953

#rmdir - Remove folder 

root@My-ThinkPad $ rmdir {foldername}  

#Remove folder permanently  

root@My-ThinkPad $ sudo rm -rf folderName

FYI: you can use letters

-f, -r, -v: 
    -f = to ignore non-existent files, never prompt
    -r = to remove directories and their contents recursively
    -v = to explain what is being done

#Run execute files 

root@My-ThinkPad $ sudo ./{filename}.run 
e.g. root@My-ThinkPad $ sudo ./bitnami-rabbitmq-3.7.6-0-linux-x64-installer.run 

#Run script files 

root@My-ThinkPad $ sh {filename}.sh

#copy file from one folder to another 

root@My-ThinkPad $ sudo cp /opt/user/1.html /opt/user1

#copy file from one computer  to another 

root@My-ThinkPad $ sudo scp /opt/user/1.html root@My-ThinkPad1:/opt/user1
#ls - Show files in directory

root@My-ThinkPad $ ls 
Desktop Downloads
Music Pictures

#Show hidden files 

root@My-ThinkPad $ ls -a
 
 
#Show hidden files with details 

root@My-ThinkPad $ ls –al 

#To create folder 

root@My-ThinkPad $ mkdir {foldername} 

#Unzip file in folder  

root@My-ThinkPad $ unzip file.zip -d destination_folder 

-d means external folder, its optional 

If the unzip command isn't already installed on your system, then run: 

root@My-ThinkPad $ sudo apt-get install unzip 
e.g. root@My-ThinkPad $ unzip glassfish-4.1.zip -d /home/hcdc/webapps/ 

 #pwd - To know which directory you are in, It gets absolute path  

root@My-ThinkPad $ pwd
/home/root

#cd- Go to directory

root@My-ThinkPad $ cd Downloads 
root@My-ThinkPad: Downloads $ 

Thursday, December 28, 2017

Paste copied text in emulator(in EditText)
How to paste text to emulator in edittext?
---------------------------------------------------
1. Open Terminal.
2. Go to sdk path e.g. D:\sdk\platform-tools
3. Type adb devices((it will list the device currently connected))
e.g.  D:\sdk\platform-tools>adb devices
4. Select Textbox where you want to write text
5. Write command: `adb shell input text 'Yourtext'` (make sure only one device is connected to run this command and that you can also use **Single Quotes**)
e.g. D:\sdk\platform-tools>adb shell input text ' भारत'6. Done!

Monday, January 16, 2017

Create Secure & zipalign apk for upload to playstore

Keystore-SSL Certificate as a Trusted Certificate



How To Get Your MD5 Fingerprint For Android Using Eclipse Keytool Plugin
---------------------------------------------------

1. Go to Help>Install New Software.
2. Now enter this website on the textbox: http://keytool.sourceforge.net/update
3. Wait until the word "Keytool" appears under the "Name" table then click on the checkbox before it.
4. Then click on "Next".
5. Continue clicking on the next choices until you're done with the installation.

http://www.icodeya.com/2011/04/how-to-get-your-md5-fingerprint-for.html


What is keytool?>
---------------------------------------------------

Keytool is an Eclipse plugin that maintains keystores and certificates.


Key features
  • Export certificate, with or without the private key.
  • Create certificate.
  • Create keystore.
  • Open existing keystore.
  • View all available information about every certificate.
  • Open existing certificate. Default with the extension .cer.
  • View list of certificates in a keystore.
  • Handles JKS and PKCS #12.
  • Show which certificate in a keystore where you have the private key.
  • Filemonitoring, to monitor changes in keystores.
  • Default opening a keystore every time Eclipse starts.
  • Generate CSR.
It allows you to create certificates and put them in a keystore.
You can from Eclipse, open and inspect certificates that are stored as .cer, or in a given keystore.



Create Zipalign apk>
---------------------------------------------------
  1. Right click on project
  2. Search & Click- Export Android Application
  3. Next
  4. Select project name
  5. Select keystore & enter password, if not existing keystore create keystore
  6. Next
  7. Select alias & password, if not exist then create
  8. Next
  9. Give destination path
  10. This page has certificate details
    • Certificate expires date
    • MD5
    • SHA1
  11. Finish (zipalign apk)

Important Note
>
---------------------------------------------------
  1. Check android_manifest.xml and verify that android:debuggable  attribute is set to false in your manifest file           
  2. Check the android:versionCode and android:versionName attributes. (if this is the first time you are uploading a apk, ignore, else if it is a new version of existing apk, make sure these       values are larger than previous apk)
  3. Export unsigned application package from Eclipse
  4. Sign the application using release key certificate(not debug key certificate)
  5. Zip align the package
  6. Upload in google play

Verify apk by zipalign>
---------------------------------------------------
  • Open cmd & go to path

    <sdk path>\sdk\tools>zipalign -c -v 4 <source apk path>

    e.g. E:\MyProject\adt-bundle-windows-x86\sdk\tools>zipalign -c -v 4 E:\MyPro
    ject\Sorghum\SorghumV3.0.apkA

    //all images/xml/assets folders
    14939764 res/drawable-xxhdpi/ic_plusone_tall_off_client.png (OK)
    14945782 classes.dex (OK - compressed)
    16127073 manifest (OK - compressed)
    16127212 META-INF/MANIFEST.MF (OK - compressed)
    16134980 META-INF/CERT.SF (OK - compressed)
    16143103 META-INF/CERT.RSA (OK - compressed)
    Verification successful

    **********************************
    Zip alignment utility
    Copyright (C) 2009 The Android Open Source Project
    Usage: zipalign [-f] [-v] <align> infile.zip outfile.zip
           zipalign -c [-v] <align> infile.zip

      <align>: alignment in bytes, e.g. '4' provides 32-bit alignment
      -c: check alignment only (does not modify file)
      -f: overwrite existing outfile.zip
      -v: verbose output

Tuesday, May 17, 2016

Import/Export Database in command line

Import mysql DB in command line
>
---------------------------------------------------


  • C:\wamp\bin\mysql\mysql5.6.12\bin>mysql -u(username) -p (database) < path
    Enter password: *******   
  • C:\wamp\bin\mysql\mysql5.6.12\bin>

  • e.g.
     C:\wamp\bin\mysql\mysql5.6.12\bin>mysql -u root -p db_avm < C:\wamp\www\AVMV1\db_avm.sql
    Enter password: *******



    C:\wamp\bin\mysql\mysql5.6.12\bin>



    Export mysql DB in command line>
    ---------------------------------------------------



  • C:\wamp\bin\mysql\mysql5.6.12\bin>mysqldump -u(username) -p (database) > path
    Enter password: *******   
  • C:\wamp\bin\mysql\mysql5.6.12\bin>

  • e.g.
     C:\wamp\bin\mysql\mysql5.6.12\bin>mysqldump -u root -p db_avm > C:\wamp\www\AVMV1\db_avm.sql
    Enter password: *******

    C:\wamp\bin\mysql\mysql5.6.12\bin>


    Tuesday, February 2, 2016

    Fix insufficient storage in android devices(mobile)

    Fix insufficient storage in android devices(mobile)


    If, for some reason, when you delete a few apps and still getting this error, then you need to do a dump state clearance.
    >Enter your Dialer
    >Dial *#9900#
    >This will access the SysDump menu

    Tuesday, June 23, 2015

    How to copy/push & delete file in sdcard(DDMS) by using commnad line in android?

    Push file to DDMS/File Explorer ->storage/sdcard/nature.jpg

    1. Go to commandline
    2. Type following path
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
    3. Type
          adb push [your file]  /storage/sdcard

          adb push E:\Images\nature.jpg  /storage/sdcard

    if u get error msg

     failed to copy 'E:\Images\nature.jpg' to '/storage/sdcard/nature.jpg': Read-only file system

    then change read only mode to write/execute mode means give full permission to '/storage/sdcard'
    for this go to following command

    4. E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell
     a.   
    root@generic:/ # su
            su
     b.   
    root@generic:/ # mount -o rw,remount rootfs /
            mount -o rw,remount rootfs /
     c.   
    root@generic:/ # chmod 777 /storage/sdcard
            chmod 777 /storage/sdcard
     d.   
    root@generic:/ # exit
            exit
     e.  
    root@generic:/ # exit
           exit

    The folder has changed mode read to write/excute mode. Then push a file to '/storage/sdcard'
    5. Type
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb  push E:\Images\nature.jpg  /storage/sdcard

     1067 KB/s (11670528 bytes in 10.677s)

    You have sucessfully transfered nature.jpg to /storage/sdcard
    You can see file in DDMS/File Explorer ->storage/sdcard/nature.jpg

    Delete file from DDMS/File Explorer ->storage/sdcard/nature.jpg

    1. Go to commandline
    2. Type following path
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
    3. Type
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell 

     a.  root@generic:/ # cd storage
           cd storage
     b.  root@generic:/storage # cd sdcard
           cd sdcard
     c.  root@generic:/storage/sdcard # rmdir nature.jpg
          rmdir nature.jpg


    Note : Make sure your dir should be empty.
    For non-empty directory use.

     d.  root@generic:/storage/sdcard # rm -r nature.jpg
          rmdir nature.jpg

    Create file/folder to DDMS/File Explorer ->storage/sdcard/test

    1. Go to commandline
    2. Type following path
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>
    3. Type
           E:\MyProject\adt-bundle-windows-x86\sdk\platform-tools>adb shell 

     a.  root@generic:/ # cd storage
           cd storage
     b.  root@generic:/storage # cd sdcard
           cd sdcard
     c.  root@generic:/storage/sdcard # mkdir test
          

    if u get error msg

    mkdir: 'test': Permission denied

    d.  root@generic:/storage/sdcard # su

    c.  root@generic:/storage/sdcard # mkdir test

    Done


    4. Go to in folder
    a. root@generic:/storage/sdcard # cd test
    b. root@generic:/storage/sdcard/test #