Why GIT?? What is GIT?

Git is SCM and VCS tool. SCM is expanded as Source Code Management means it helps to maintain the source code of the program. Any changes made or any trouble occurs, it should be reliable and should not affect the code. Since the code which are running on program files for multiple clients, if any error occurs it will affect the business. VCS is expanded as Version Control System means it helps to give version for each commit and also track the changes, if any newly added code makes trouble then we can able to rollback to previous version.

How GIT works?

  • It works on repositories, repositories which similar to workspace where do put all our codes.
  • since it works on repositories, whenever we want to use git we want to say to git that current working directory is your repository. To do we want use git init command. This will create current working directory as repository for git.
  • This area is called as working area
  • Now the code is present in GIT but the GIT will not track the code changes.
  • To make the GIT to track the code, We want to put the code in staging area
  • git add [file name] — this will put the code in staging area
  • Staging area is an area where we will be having a database in which we will store the changes made in the file and act as index for the file.
  • but this change will not be added to file’s current version, since GIT is VCS, changes made should be stored in new version.
  • To make the change to get effect we should commit the change, then new version of the file is updated.
  • git commit [filename] -m “ [commit message]” — is the command used to make new version of the file.
  • git reflog, git log and — oneline are the commands use to see the version details of the file
  • branching is a concept in which we will be providing the main code to developer and ask them to add new features and commit the version, by this we will be to see the work done by the developers in separate version without affecting the main code
  • once we create GIT repository it will create default master branch, here will be coding the main code
  • once developers finish the code they can ask for the master to merge the code with new version.
  • some conflict will occur while merging called merge conflict due to difference in code.
  • we can also set upstream from master branch to other branch this will track the other branch version and staging.
  • while merging we have different strategy of merging like fast forward merging, recursive, squash, etc
  • fast forward is normal merging strategy
  • squash is kind of merge where the master and branch directly, master merge the branch without tracking the all the version in branch.
  • squash give final commit this commit does not contain the version in the branch
  • git cherry-pick [version id] — will pick the particular version and merge
  • git rebase master — it will reset the main code in branch version
  • git reset — it will put file from commit area to staging area
  • one version have one parent version id and in some usecase we will have two parent version id
  • git cat-file -p [id] — display the container object
  • versions arranged in tree
  • to give version id, it will be using hashing technology
  • git checkout filename -to undo

GITHUB ??

  • It is similar to GIT but it works on remotely
  • so that the developers from different location can put and retrieve code easily
  • we can also make it public or make it private to restricted user
  • This helps in CICD
  • git remote -v — to check remote connection
  • git remote add [anyname] [github url]
  • git pull — bring the remote repo
  • git fetch — bring history/log
  • git diff [version ids]
  • git push -u provides tracker to local master for remote master branch and this will help us to say that ahead or behind the remote and local repo
  • git clone url — download the code from github

Use cases:

  • hook — helps to alert when the commit is done and this helps to know the changes made and can rollback the change when it is unnecessary and unauthorized.
  • with help of jenkins we can achieve continuous integration continuous development and whenever we commit it will push automatically
  • the change in code will reflect in server
  • Whenever CVCS like github, we can make local git server and connect with another git server so that it will act as distributed system and no need of centralized system

Tools:

  • p4vmerge tool — used to find the difference in code and easy to identify the merge conflict
  • GITkraken — it is GUI representation git which will easy to see version and branching and identify the flow easily.

Thanks for vimal daga sir for providing this wonderful session on GIT and GITHUB. It gives us strong basement.

#worldrecordholder #gitbylw #gitandgithub #righteducation #We_are_ARTH_Learners

Thank you,

cheers

learning things that never get exhausted

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store