Selenium Integration with Git and GitHub

In this post we will discuss about following things:
  • What do you mean by CM and what is SCM tool?
  • Why do we use SCM tools and advantages
  • What is Git and GitHub?
  • Basic Architecture
  • Steps to work with Git and GitHub
  • How to install Git
  • Demo – execute different commands using cmd
What is CM and what are diff SCM tool?
  • Configuration management(CM) is managing the configuration of all of the project's key products and assets.
  • SCM stands for Source Code Management is an integral part of any project in the IT world.
  • Important component in DeveOps culture. 
  • Source Code Management or Version Control Systems in any project ensure all the members of a team stay on top of the source code changes.
  • SCM practices include revision control and the establishment of baselines.
Top SCM Tools:
  • MS Team Foundation Server (TFS):
  • Kallithea - Open Source
  • GitLab - Continuous Integration (CI), Continuous Delivery (CD) is an integral part of GitLab
  • Bitbucket Server:
  • Subversion (SVN):
  • Git and GitHub
Why do we use version control System?
  • Collaboration- Without a SCM in place, you're probably working together in a shared folder on the same set of files. It's extremely error prone, someone will overwrite someone else's changes. With a SCM, everybody on the team is able to work absolutely freely - on any file at any time. 
  • Storing Versions
  • Restoring Previous Versions
  • Understanding What Happened: Every time you save a new version of your project, your SCM requires you to provide a short description of what was changed. This helps you understand how your project evolved between versions.
  • Backup
Now lets talk about Git and GitHub

Git and GitHub
  • Git – initially developed by Linus Torvalds is a version control system.
  • Git is a version control system that lets you manage and keep track of your source code history. 
  • GitHub is a cloud-based hosting service that lets you manage Git repositories.
Different Terminologies with GitHub

Repository: You can simply, treat it as a storage area of your workplace that contains all your documentation files and the history of changes.
Clone: Clones are literally clones (copies) of a repository that sit on the developer’s computer instead of a server elsewhere.
Commit: Whatever the changes you make in your files will come under commit. Every change is saved under a particular name or ID which is also called “revision”.
Push: Pushing refers to sending your committed changes to a remote repository such as GitHub.com.

Pull Request: If you have made changes in code/script, to show the other collaborators you send a pull request.
Fork: It is a copy of other's repository in your account in which you can make changes and it won't affect the original code.
Branching: When you extract a portion /section of code from the main or remote track of your software, then it is called ‘branch' and the process is known as Branching.
Fetch: Fetching refers to getting the latest changes from an online repository (like GitHub.com) without merging them in.
Merge: Merging takes the changes from one branch (in the same repository or from a fork), and applies them into another.
Git and GitHub

Steps to work with Git and GiHub
  • Download and Install Git - https://git-scm.com/download/win , https://git-scm.com/download/mac (Please refer below YouTube video at 27:00 minute for download/installation of Git)
  • Create a GitHub Account
  • Using Command Prompt - by using different git commands
  • Using Eclipse -  we have inbuilt Git plugin in eclipse
Please refer below different git commands:
1. git config
This command sets the author name and email address respectively to be used with your commits.
git config global user.name [name]  
git config global user.email [email address]
Example: 
git config user.name "Hitendra Kuamar Verma"
git config user.email "Hitendra@Hitendra-PC"

2. git init
This command is used to start a new repository.
git init [repository path
Example: navigate to repo path and
git init

3. git clone
This command is used to obtain a repository from an existing URL.
git clone [url]  
Example: navigate to your repo path where you want to clone and write below command in cmd
git clone https://github.com/hverma22/Test2

4. git add
This command adds a file to the staging area.
git add [file] 
Example: 
git add [file]
git add *  
git add .

5. git commit
git commit -m [commit message] 
This command records or snapshots the file permanently in the version history. 
Example:
git commit -m First Commit

6. git diff
This command shows the file differences which are not yet staged.
Example:
git diff -staged
git diff [first branch] [second branch]  

7. git reset
This command unstages the file, but it preserves the file contents.
git reset [file]  
git reset [commit]  
git reset hard [commit]

8. git status
git status  
This command lists all the files that have to be committed.

9. git rm
This command deletes the file from your working directory and stages the deletion.
git rm [file] 

10. git branch
git branch  
This command lists all the local branches in the current repository.
Example:
git master

11. git log
git log  
This command is used to list the version history for the current branch.
Example:
git log --online

12. git merge
git merge [branch name]  
This command merges the specified branchs history into the current branch.

13. git remote add [variable name] [Remote Server Link]  
This command is used to connect your local repository to the remote server.
Example:
git remote add origin https://github.com/hverma22/Test5

14. git push
git push [variable name] master  
This command sends the committed changes of master branch to your remote repository.
Example:
git push origin master
git push origin master --force

15. git pull
git pull [Repository Link]  
This command fetches and merges changes on the remote server to your working directory.
Example:
git pull https://github.com/hverma22/Test2.git

16. git show
git show [commit]  
This command shows the metadata and content changes of the specified commit.
Command: git show <ChangeID>:<FilePath>
Example: 
git show 45dhfg56:/src/test/newtest.xml

17. Checkout
git checkout [branch name]  
This command is used to switch from one branch to another or You can get the specific previous version.
Command: git checkout <ChangeID> <filePath with extenion>
Example:
git checkout 6475fgh5 pom.xml

Please refer below video to understand better. We have covered the following scenarios:
  • Create a new Project and Add your fresh project into Github (into existing repository) 
 Add all project files
 Make the change in the code and push the code
  • How to pull the code when someone make the changes.
  • How to checkout the particular version.
  • How to work with existing repository- Clone a existing repository
YouTube video: Part A - Introduction to SCM tools and Demo of Git and GitHub using Command Line

YouTube Video Part B - How To Add Eclipse Project To GitHub | How to Commit, Push, Pull and Checkout




YouTube Video Part C - Branching, Merging and Conflict Resolution using Eclipse

2 comments:

  1. Very Useful, informative and easy to understand. Thanks.

    ReplyDelete
  2. Nice and simple in word, anyone can easily understand.

    ReplyDelete