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 “Your Name”$ git config –global “[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$ 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

Git Basics and Installtion Read More »

All about Git

About Git Git is a Source Code Management Tool.It is a free and open-source version control system.Git helps to keep track of different versions of a single code base by tracking all changes.Git is Distributed Version Control System(DVCS). Stages in git Workspace/Working directory Staging area Local Repository Workspace:- it is your working directory Staging Area:- Local repo:- Git CommitIt stores changes in repositoryIt uses SHA-1 checksum conceptIf you change anything in code then commit id will be changedYou can easily track changes through commit id Tags in gitTag assigns a meaningful name with a specific version in repository, like we let some change in code and assign tag with commit id to identify its easily. Git PushWhen we done with our code and went to add the code in remote repository, then we will use the push command to transfer the code from local repository to remote repository. Git PullPull command copy the code from remote repository to local repository Branch in GitBranch is a place where your code is placed, it may be master or main branch.Each task has one separate branch. Branch Merge Branch merge means if someone working some other code and you went to add their code in your branch/code then merge command will be use. Git Conflict When same file having different content in different branches, git conflict occurs when you merge them in single branch. Git Stashing Git stashing is a temporary storage for your code, it mean if your are working on new project and someone told you to work on old project, in this case you can store your new project in stashing area for few hours. Git ResetIt is powerful command that is used to reset local changes to the state of git repository. We will use this command when we want to discard the changes, it will revert the commit id to previous commit id. Git RevertThe revert command helps you to create new commit and it will create new commit which is opposite to existing commit without deleting data.

All about Git Read More »