Git Basics and Installtion
Git Basics Install git on Linux Step:- 1 Open your Terminal and run the below commands $ sudo apt-get update $ sudo apt-get install git Step:- 2 Verify the installation was successful by running below command $ git –version Configure git in local system Step:- 1. Open your terminal run the following commands $ git config –global user.name “Your Name”$ git config –global user.email “[email protected]”$ git config –list Example Let’s work with Git and Github Open your terminal and create one directory for git work $ mkdir redient-git$ cd redient-git/$ git init Example:- Now Create one file and write some lines $ sudo nano redient After saving file, run the following command $ git status Output The file is in workspace, and move it to staging area by the following command $ git add .$ git status output:- Now lets move this file from staging to Local repo and add our first commit $ git commit -m “this is my first commit”$ git status output: Now if you are working with team and went to know who commited to code then run the following commnad $ git log To see code using commit id $ git show <commit-id> Now push this code in Github, first login to github and create one repository their, below i have created one repo in my account Now run the below remote origin command $ git remote add origin https://github.com/redient-security/sredient.git$ git remote show origin Now run the push command $ git push -u origin master Type your username and password You face token error here to resolve it we need to create a token In github account, first go to setting then scroll down and click on Developer settings, Now click on Personal access tokens and now create one token here After creating token, now run again the same command and this time instead typing password, paste your github token and hit enter $ git push -u origin master Now got to github account and check your repository Now the code is successfully pushed in Github account if you want to pull it from github, run the following command $ git pull origin master