Git and CMD Tutorial

 Git

#View git public repo in code editor view

https://github1s.com/


//From Local to Git

1. Push from the local to git first time

git init

git add .

git commit -m "business creation and product creation feature added"

git branch -M server

git remote add origin https://github.com/iphone201988/skwad.git

git push -u origin main //if not work then

git push origin main -f


2. Push from the local to git from second time:

git add .

git commit -m "business creation and product creation feature added"

git branch -M

git push origin


// From git to  server

1. pull on the live server for first time:

git stash //uses: discard local changes

git remote add origin https://github.com/iphone201988/skwad.git

git pull origin main


2. pull on the live server second time:

git stash //uses: discard local changes

git pull origin



error: No such remote 'origin'

remove all git bash using:

rm -R .git

then start with fresh



#Fresh Git from local

git init

git add .

git commit -m "first commit"

git branch -M main

git remote add origin https://github.com/iphone201988/skwad.git

git push -u origin main



#If we work with team on git: (first setup the project by pull the develop branch) git pull <url>

git pull <url> <specific branch> //pull from specific branch (then.....) git add . git commit -m "message" git pull origin develop git push origin your_branch



#create new branch

git branch new_branch_name


#swith to new created branch git checkout new_branch_name


#set default streem to use only git push: git push --set-upstream origin branch_name

#Change git account in Windows:

you need to open the credential manager of your computer (Win or Mac) and update the credentials there Here is how it look on windows


1. Search for "Credential Manager"

2. Remove the old account from here
3. try again to push the code, you can verify the account easily which you want to use 



#Server login in terminal login:

ssh -i 'path_of_pem file' user@ip_address

Example=>

ssh -i '/home/techwinlabs/Downloads/Dutp.pem' ubuntu@18.587.45.69

ssh -i /Downloads/Rewp.pem ubuntu@18.587.45.69


Basic sever login from terminal into any hosting:

ssh user_name@dedicated_ip_address

Example: ssh techmanish@85.65.578.589


Some Basic git Command

touch => to create new file
ex: $ touch index.html
git config --global user.name => to view user name
git config --global user.email=> to view user email
git status => status of all files of this directory
git checkout -f => all file math to the last commit. this command is used when you went wrong. (recover the files from last commit)
git log => view commit history
git log -p -3 => view last 3 commit with all changes
git diff =>compare the working file with staging area file 
git diff --staged => compare the staging area file to last commit
git commit -a -m "message" => to commit the modified files with skip the adding file in staging area 
git rm file_name => delete file from the git repository. in the working directory file comeback into untrack file
git rm -f file_name => delete file from the git repository if facing any problem when deleting the file.
git status -s => short status of all files


CMD

1. code .=> to open visual studio code
2. clear =>to clean the screen
3. ls => to view files & folder
4. ls -lart =>to view all files & folder (including hidden files)
5. div => Get All directory list
6. <Tab Button> => suggest the file name by clicking on tab
example: cd a <tab button>
5. file_name.txt=> open any file in terminal
Example: 
C:\Users\user\Downloads>file.txt  (if not space in file name)
C:\Users\user\Downloads>"file name.txt"  (if space in file name)


  1. cls: Clear the screen
  2. cd folder_name: Change directory
  3. cd \ : back to root directory
  4. cd.. : back to directory
  5. d: = goto d drive 
  6. dir: show all files in directory
  7. mkdir folder_name: make directory (for creating a new folder)
  8. systeminfo: all computer details (including Ram, processor, hardware, windows)




Post a Comment

0 Comments

Visual Studio