Lets learn about github

Posted By : Palak Tiwari | 24-Dec-2018

What is GitHub?
Introduction:-

GitHub is a code facilitating stage for variant control and coordinated effort. It gives you and others a chance to cooperate together from anywhere. Git is an update control framework, an apparatus to deal with your source code history. 

 It has the following essentials :

Repositories
Commits
Branches
Pull Requests
 Prerequisites : 

 

1. Github account

2. Code which needs to be pushed

 

Steps of explanation:-

 

Let’s follow these steps:-

 

Step 1.  Let’s create a repository :

 

 It basically used for the single project. It holds many different items like images, spreadsheets, videos, data sets or anything which your project has with it.

1.Steps to create a new repository :

2. Click on the + icon, which is at the upper right corner then select “new repository”.

3. Name your repository acc to your project name.

4. Write a short description.

5. In the end, we  have two  option

 

 

a)Public: Anyone can see this repo. You choose who can commit.

b)Private: You choose who can see and commit to this repo.

Another checkbox of “Initialize this repo with a “READ ME”. Clicked this checkbox, will let you immediately clone the repository to your system. Skip this step if you are already importing an existing project.

 

Step 2. Create a branch

 

 

Branching: It’s a way to work on different versions of the project at the same time. 

By default, we have one branch name which is called a “master “ branch. We use different branches to do an experiment then merge it into the master branch. If any other person made some changes to the master branch while you were working on your branch then you could pull in those updates.

  To create a new branch:-

 

1. Go to your new repository “Practice “.

 

2. Click on the drop-down and then give any name for the new branch. 

 

Step 3. Make and commit changes  

 

 

Now you are on code view section of your  “new branch“. Its a copy of the master branch. Let’s do some edits.

Saved changes are called  “commits”. Each commit has associated descriptive message with it which basically tells about why and for which purpose particular commit has made.

Make and commit changes :  

 

1. Click the README.md file.

 

2. Click on the pencil icon which is available on the upper right corner of the file view to edit.

 

3. In the editor, write a short note about yourself.

 

4. Write your commit message

 

5. Click on the “commit changes” button.

 

Step 4. Open a pull request:- 

 

When you open a pull request you are basically informing someone’s to review your changes, take pull in and merge it into their branch.

a. Click on the pull request tab then click on the pull request button which is in green color.

b. In the example comparison, select the branch you made and then compare it with the master branch.

c. Look over the differences and from here you should know what you want to submit.

d. When you are sure with your changes then click on the big green button of “ create pull request “.

e. Add a description with it.

 

Step 5. Merge pull request:-

a. Then click on the “Merge pull request”  

b.Go ahead and delete this branch since all changes have been incorporated.

 

Alternative:-

Now let’s discuss some useful commands for a push, pull and commit through terminal:-

 

1. Click on “clone or download”  then copy the URL of the project from the right side of the git.

 

2. To  get a clone:-  git clone  https://github.com/palaktiwari/Practice.git

 

3. To create a new branch:-  git checkout -b "branch name"

 

4.To checkout:-   git checkout  

 

eg if you are currently on the master branch and then you want to switch to developer branch.

 

5. Then copy the project file and then paste it into a local folder.

 

6. To get the current status:- git status command is used.

 

7. To stage the file to commit to your local repo:- git add  .  command is used. Here “.” denotes a current directory.

 

8. If you want to add only a single file then git add “ path of the file”  command is used.

 

9. To commit the file that you have staged into your local repo:- git commit -m "Amazon" is used. Here “Amazon” is project name. 

 

10. To take pull: - git pull origin New-branch, Where “New-branch “ is the newly created branch. 

 

11. To push the code:- git push origin New-branch 

 

12. In the above command of git push, you have to enter user name and password of your Github account.

 

 Conclusion:-

Here we have learned how to push your code from local to the remote repository through different steps like push, pull, commit etc.

References:- 

https://guides.github.com/activities/hello-world/

 

 

 

 

 

 

 

 

 

 

 

 

 

 
Related Tags

About Author

Author Image
Palak Tiwari

Software tester with good knowledge testing skills in various areas. She believes in continuous learning .

Request for Proposal

Name is required

Comment is required

Sending message..