Wednesday, March 6, 2019

Git and linux common command


Git commnad

  1. git init: (Initialize the local directory as a Git repository.)
  2. git add: (Add the files in your new local repository. and staging)
  3. git reset HEAD file_name: (for unstage)
  4. git commit -m "First commit" (commit the code)
  5. git remote add origin remote_repository_url (Sets the new remote)
  6. git pull origin development : (pull from remote)
  7. git push origin master (push the code)
  8. git config --list (show the git config )
  9. git config --system --unset credential.helper
    git config --global --unset credential.helper
    git config --global credential.helper manage (chage the git config: u can use any one maybe)
  10. git log --oneline -5
  11. git log --oneline -5 origin/development
  12. git branch
  13. git checkout branch_name  
  14. git cherry-pick sha1
  15. git commit --amend 
  16. git reset HEAD~ ( git reset last commit)
  17. git marge <branch_name> you have to location destination branch(like master)
    1. let now you are in master branch and want to marge branch1
      1. so command lik git marge branch1
  18. git cherry-pick <sha1> cherry pick is used to replace in the top of current branch.
  19. git checkout <prev_sha1> <filename>  file change to sha1 commited file
  20. git push origin -u <branch_name> it will create a branch in remote. -u = upstream
  21. git stash    "current changes keep in the drap mode"
  22. git stash pop
  23. git stash list
  24. git checkout . "that means current change will be removed"
  25. git reset c602b9fc --hard   " it will remove all the commit after c602b9fc and head will be c602b9fc"
  26. merge is used to merge two branches. follow the two steps
    1. git checkout master 
    2. git marge <features1> merge is used to merge two branches
     



git reset c602b9fc --hard
git push origin master --force



     


https://help.github.com/en/articles/adding-an-existing-project-to-github-using-the-command-line

Linux common command:

  1. sudo tail -n 20 /var/log/nginx/error.log  (to see the log of nginx server)
  2. chmod -R <permissionsettings> <dirname> (change the folder permision and its subfolder and files)
    1. chmod 755 -R  <folder-name>
  3. pwd (to check the current directory) 
  4.  cat <filename> : is used to check file text
  5. file edit way:********* ()
    1.  vi filename
    2.  (Enter) i
    3.  change the text
    4.  Esc
    5.  :wq
    6.  enter
  6. exit file without saving
    1. :q (enter)
  7. Access EC2 using ssh
    1. chmod 400 SPWStaging-ASDAccount.pem (first time)
    2. ssh -i "SPWStaging-ASDAccount.pem" ec2-user@ec2-18-212-2-219.compute-1.amazonaws.com
    3. sudo su (ec2-user is used as a super user)
  8. wget <url> to download the from internet
  9. unzip to extrac the file in linux
  10. sudo useradd <user_name>  adding user in linux
  11. sudo passwd <user_name>  set the password
  12. sudo userdel <user_name> deleting the user
  13. sudo groupadd <groupd_name> add the group in linux command
  14. sudo touch <file_name>  create the file
  15. sudo vi <file_name> to open the file in file text check 5 point
  16. sudo cp <file_name> <folder_name> copy the file to specific folder
  17. sudo mv <file_name> <folder_name> to move the file
  18. sudo rm <file_name> to remove the file
  19. sudo mkdir <directory_name> to create a directory in linux
  20. sudo rmdir <directory_name> to remove the directory in Linux
  21. sudo grep -i <string_name> <file_name> just like as ctrl+f features in command line. Flag: -n, -v,-c, -i
  22. sudo sort <file_name> sort the file string
  23. ls -l  to show the file list with permission
  24. chown <user_name> <file_name> to change ownership of file like "Tushar(user) to root user"
  25. chmod <permission_number (777)> <file_name>  (pronounce: ch-mod/ch-own)
    1. 777 means 
    2. first 7 = user permission
    3. second 7 = group permission
    4. third 7 = other user of that group user
  26. id - show the user id
  27. tar -cvf <file_name> <source_folder_name>  to zip as the file
  28. tar -xvf <file_name> unzip tar the file
  29. cut -c1-2 <file_name> to cut the string from the file. here c means column  from 1 to 2
  30. sed 's/<replaced_string>/<replace_by_string>' <file_name>
    1. to replace the string in file
  31. history <last_history_showing_number>  show the list of history
    1. history 5 
  32. free -k/-m is used to check memory space in the system
  33. ssh-keygen -t rsa  to create public private key to get access. from the next time just type enter
    1. to generat  the key

  34. ifconfig / ip a  to check the ip address
  35. env for the environment variale
  36. sudo app-get install pinta   to install the software in ubuntu
  37. scp -i ec2-access.pem /home/cefalo/Tushar/a2n/boilerplate/sveltekit/node_modules.zip ubuntu@ec2-63-33-70-8.eu-west-1.compute.amazonaws.com:/opt/boilerplate/boilerplate-sveltekit    // upload local zip to aws ec2

Ref:
  1. https://hackr.io/blog/basic-linux-commands
  2. https://www.computerhope.com/unix/uchown.htm
  3. https://www.edureka.co/blog/linux-commands/
  4. https://www.guru99.com/must-know-linux-commands.html
  5. https://www.howtogeek.com/412055/37-important-linux-commands-you-should-know/







ggggggggggggggggggg






No comments:

Post a Comment