top of page
Search
Writer's pictureCoding Camp

Install Git, Create repository and upload selenium code in Git

Updated: Jan 21, 2021

Git is a commonly used distributed version-control system for tracking changes in any set of files. It is designed for coordinating work among programmers cooperating on source code during software development.


Git also makes collaboration easier, allowing changes by multiple people to all be merged into one source.


Now Let's see how to set up git,



Step 1: Download Git

  • You can download Git here.

  • Once downloaded, click Next until it finishes installation. You can now see GIT bash option available to work on git.

  • Open Command prompt and type "git" to check whether your installation is successful.



Step 2: Create remote repository


Storing a copy of your Git repo with an online host (such as GitHub or Bitbucket) gives you a centrally located place where you can upload your changes and download changes from others, letting you collaborate more easily with others.


In our tutorial, we are going to use GitHub to create repository.

  • Sign up with GitHub to create a new repository.

  • Click on "New" button to create your new repository.

  • Enter a repository name and click "create repository"


Step 3: Upload your code to repository.


You can upload code in two ways.

  1. via command prompt/GIT bash

  2. via Eclipse plugin

1.Upload code via GIT bash:

  1. Create a local folder and put all your required code files and other folders in that folder.

  2. Right click -> Git bash here


3. Initialize your git, connect it to your remote repository and add your files by entering following commands.

//to initialize your repository
git init
//to link the local repository to an empty GitHub repository
git remote add origin [url]

You can copy your URL from your github repository.



Now you can add your folders to your remote repository by using the following commands.


//to add your files or changes to repository
git add [file]
//to commit your added files
git commit -m "[descriptive message]"
//Uploads all local branch commits to GitHub
git push
//to check the status of files
git status




Now you can see, you remote repository is updated with the files you have in your local repository.


2. Upload code via Eclipse IDE


Before we start selenium and git hub integration, we need to install and setup Maven in Eclipse.


EGit is a plugin for Eclipse which allows you to interface with Git. Since version control is becoming less and less optional, EGit now comes pre-installed with Eclipse downloads! In case you do have an older version of Eclipse, install EGit by following below steps.


  • Once EGit is installed, click Windows->Preferences -> Team->Git->Configuration and set Git username and email address as key and value.

  • Now create a local repository. Right click on the project you want to upload in git, Team -> Share Project.. -> Enter the path you want your repository to be created -> Create repository -> Finish.



Once you have shared your project, click on the files you want to add to repository, right click -> team -> Add to Index.

Once you have added the files, you will see folders changed sign from '?' to asterisk.

Now to commit your files, right click-> team->commit. Git Staging dialog box appears, enter the commit message and click "commit and push"

Push dialog box appears, Enter the remote repository URI, Username and password in Authentication section and click Next.

Select the Branch you want to commit your changes to and click Next.


Login pop up appears to fill in the username and Password details.

Once you commit your changes, you can see the icon on the folders updated.

You can see the changes reflected in your remote repository.

You can create a new branch by clicking Team->switch To->New branch and create your branch.



You can see your new branch is created in your GIT repository.


Thank you!! Happy Coding!!!


90 views0 comments

Recent Posts

See All

Smallest String With A Given Numeric Value

The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the...

Commentaires


bottom of page