Git - the most common version control system! Github - stores git repositories online. multiple online vcs are present in market like gitlab, bitbucket etc.. A Git repo can have any type of files - code, txt, images, jar files Benefits of a version control system Stores history of changes made to each and every file
why/what/when/who of a change Makes collaboration easy Local and remote repository Repository -
Folders configured to use Git it has commit -> checkpoint Local repository -
repository we have on our local system Remote repository -
repository available online like in gitlab, github etc. two types of files in git
Untracked file (U) Modified file (M) Added (A) -> in staging area first we have to move any file/update in staging area and then commit Why making updates directly to the “master” branch isn’t recommended?
Possibility of buggy code
Pulled by other developers Released to customers if auto-deployment is set up from master branch Allows to create a copy of the current master branch and work on it separately Avoids needing to add commits to the master branch immediately Commits in the new branch can be merged to the master branch once your code is ready and tested Can create a branch for
Different features Different teams Different product releases (eg: Feb release) branch structure mostly like this
master -> dev -> feature_branch To initalise git in local to any of the non git folder git init will convert simple folder to reposiratoryit will enable git inside this folder it will create one empty .git folder inside folder to make it reposiratory this is only first time process. clone/Copy the remote repository into local git clone https://github.com/codeisgod/Git_Tutorial.git
this is only first time process. it will create new reposiratory in local including .git folder and also contain previous commit (if any). to link your local repository to remote copy local repository to remote git remote add origin <git url>
Moved to staging area
staging area: a place throgh which we can decide what all file to be commit. git add <folder or file_name>
if we have to add all changes
move all changes files to staging commit the added file with comment message (added in local) before commit -> we have to use git add it creates a commit -> basically checkpoint git commit -m "<Commit_message>"
uploading commit to remote in the same branch where you are available when we are not clear with branch git push <origin_name> <branch_name>
git push origin master
if sometime, remote repository is ahead of local -> to download update from remote git pull origin <branch_name>
To view all commit history
git log git branch <new_branch_name>
to checkout the commit -> what we did in that perticular commit -> to see codebase of any time
git checkout <commit_id> to comeback to latest changes
git checkout <master/main/branch_name> create new branch and checkout to that branch git checkout -b <branch_name>
to merge from other repo to main/master repo be in branch where you want to branch git merge <branch_to_merge>
use git push after this to push in master