top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

GIT TUTORIAL STEP BY STEP AND CODE EXECUTION THROUGH JENKINS[part-1]

Step-by-Step GitHub Guidelines For Beginners


In this blog, we will be learning about Git and connection between local git and remote git(GitHub).

By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. A staggering number of software projects rely on Git for version control, including commercial projects as well as open source. Developers who have worked with Git are well represented in the pool of available software development talent and it works well on a wide range of operating systems and IDEs (Integrated Development Environments).

Having a distributed architecture, Git is an example of a DVCS (hence Distributed Version Control System). Rather than have only one single place for the full version history of the software as is common in once-popular version control systems like CVS or Subversion (also known as SVN), in Git, every developer's working copy of the code is also a repository that can contain the full history of all changes.

In addition to being distributed, Git has been designed with performance, security and flexibility in mind. Git is a tool that programmers use to upload their code to servers online so they can write a program from many different computers, create different versions of their programs, revert their changes if they upload broken code, as well as collaborating with other team members and many other reasons.

Here is the tutorial for git usage to upload our project by doing commit, push, merge and pull operations between two users.

Here are the topics covered below

  • Overview of GIT

  • Creating a local repository

  • Working locally

  • Interacting with a remote repository

  • Branching


  • Overview of GIT

Git is an open-source, version control tool created by developers . GitHub is a company founded in 2008 that makes tools which integrate with git. You do not need GitHub to use git, but you cannot use GitHub without using git.There are many other alternatives to GitHub, such as GitLab, BitBucket, and “host-your-own” solutions such as gogs and gittea. All of these are referred to in git-speak as “remotes”, and all are completely optional. You do not need to use a remote to use git, but it will make sharing your code with others easier.

Code is uploaded to a place called a “repository,” or a repo. Each repository can have many different “branches” that hold different versions of a program or, in our case, different assignments. A Git repository that you are working on may have many different branches, but you can only have one of those branches downloaded to your computer at a time.




  • Creating a local repository

Before we even start to work with the Git repositories online or on your computer, you need to add your Git username and email. Setting this information lets other people know who did what in a certain Git repo and is required to use Git. Then create a local repository by following steps,



After getting into your local repositories click on New to create a new repository.



Enter repository name, description and click on create repository. Now your new repository is created.



To share our project from your system to GIT, You need to copy the HTTPS link as mentioned below.



-> Using SSH Keys with Git

SSH keys are used with GitLab and GitHub to prove your identity so you don’t have to enter your username and password to the Git server every time that you upload code to the servers. Using SSH keys is not required to use Git, but they make long term use simpler.



-> Start Using Git

Once u created and executed a new project in your local system you need to follow few steps to share your project from your local system to git repository.


STEP 1:


STEP 2:


  • Interacting with a remote repository

Git requires a few steps to get code that is online onto your computer, but these steps only need to be completed once per Git repository. After the initial start up, only a few steps are used. There are two ways to initialize a Git repository on your computer: Cloning and Manual Setup. You can import project from third person repository by copying URL from repository where you want to retrieve from.



To import the code to your local computer go to eclipse->right click and select import.



You can either choose Projects from Git or Projects from Git(with smart import). Either way works well to import a project from Git.



Select Clone URI to get the project from respective repository.




Give the Repo URI where you want to retrieve from.If you use https URL then need to enter Git Username and Password each time.You can avoid entering username and password multiple times by using SSH.



Specify the branch name and select fetching.




Enter the local Git storage path to store the project.



Now click on Finish and the project has been imported successfully.



The imported project will be added to eclipse project explorer as you can see below.


  • Working locally

Creating a fork from a remote repository will give access to you to add your code by doing commit and push operations from your eclipse workspace. To create a fork go to third-party repository which you used to import the project and click fork option and the select create a fork.




Enter a name which is relevant to the project name and make sure the option Copy the master branch only is enabled then click Create Fork. Now two people can work under same Github.



To make sure your fork is created refresh the page and go to your repositories.You can see your forked repo with the third-party repo underneath as below.



  • Branching

A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. As you start making commits, you’re given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically.

One of the biggest advantages of Git is its branching capabilities. Unlike centralized version control systems, Git branches are cheap and easy to merge. This facilitates the feature branch workflow popular with many Git users. Feature branches provide an isolated environment for every change to your codebase.

Creating a new branch from master is always to safe to commit your code locally and check if any changes made and then merge into master branch of your own or third-party branch. To create a branch from your forked repo.



Now the new branch is created from master branch.


Conclusion


Branching allows teams of developers to easily collaborate inside of one central code base. When a developer creates a branch, the version control system creates a copy of the code base at that point in time. Changes to the branch don't affect other developers on the team.

Three things about branching to keep in mind are:

1) streamline workflow,

2) collaboration, and

3) continuous parallel development.

Source control branching saves time and effort in an agile environment while promoting productivity. This is true for a lone writer or for a team of content developers. Part of this concepts Merging ,Working with third party contributors and Pulling code locally are coming in part-2. I have attached part-2 link below,find it useful.


Hope You are able to understand the git process through this blog. Leave your valuable comments. Happy Learning.

Part-2:


147 views0 comments
bottom of page