Github Tutorial PDF
Github Tutorial PDF
Github Tutorial PDF
GitHub
TUTORIAL
Small Codes
Programming Simplified
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, SmlCodes.com, nor its dealers or
distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Smlcodes.com has endeavored to provide trademark information about all the companies
and products mentioned in this book by the appropriate use of capitals. However,
SmlCodes.com Publishing cannot guarantee the accuracy of this information.
If you discover any errors on our website or in this tutorial, please notify us at
support@smlcodes.com or smlcodes@gmail.com
Author Credits
Name : Satya Kaveti
Email : hello@smlcodes.com
Website : http:/smlcodes.com
Digital Partners
2|P A G E
...................................................................................................................................................................... 1
T U T O R I A L.......................................................................................................................................................................... 1
GITHUB TUTORIAL............................................................................................................................................................ 1
1. INTRODUCTION......................................................................................................................................................... 4
2. CREATE GITHUB ACCOUNT.................................................................................................................................. 4
3. GITHUB WORKFLOW ................................................................................................................................................ 4
4. WORKING WITH GITHUB........................................................................................................................................ 5
3|P A G E
1. Introduction
GitHub is a code hosting platform for version control and collaboration. It lets you and
others work together on projects from anywhere.
This tutorial teaches you GitHub essentials like repositories, branches, commits, and Pull Requests.
Youll create your own Hello World repository and learn GitHubs Pull Request workflow, a popular way to
create and review code
3. GitHub Workflow
GitHub Flow is a lightweight, branch-based workflow that supports teams and projects where
deployments are made regularly.
4|P A G E
1. Create a branch from the repository.
2. Create, edit, rename, move, or delete files.
3. Send a pull request from your branch with your proposed changes to kick off a discussion.
4. Make changes on your branch as needed. Your pull request will update automatically.
5. Merge the pull request once the branch is ready to be merged.
6. Tidy up your branches using the delete button in the pull request or on the branches page.
1.In the upper right corner, next to your avatar or identicon, click and then select New repository.
5|P A G E
2.Name your repository,write a short description,Select Initialize this repository with a README.
3.On Clicking Create repository it will creates the new repository and it is ready for commit the code.
6|P A G E
4.2 Adding files to Repository
We can add the files in two ways in GitHub. creating new file
Provide file name, enter the code you want, give some commit message & say commit new file it
will create file in the repository
7|P A G E
2.Upload files from your PC
On GitHub, saved changes are called commits. Each commit has an associated commit message,
which is a description explaining why a particular change was made. Commit messages capture the
history of your changes, so other contributors can understand what youve done and why.
8|P A G E
4.3 Create a Branch in GitHub
Branching is the way to work on different versions of a repository at one time.
By default your repository has one branch named master which is considered to be the definitive
branch. We use branches to experiment and make edits before committing them to master.
I want to create a new branch named feature, Here the Steps to do so.
2. Click the drop down at the top of the file list that says branch: master.
3. Type a branch name, feature, into the new branch text box.
4. Select the blue Create branch box or hit Enter on your keyboard.
Here adevelopers, writers, and designers use branches for keeping bug fixes and feature work separate
from our master (production) branch. When a change is ready, they merge their branch into master.
Pull requests show diffs, or differences, of the content from both branches. The changes,
additions, and subtractions are shown in green and red.
Here I made changes in index.html, I added new line in feature/index.html. See how we can create
Pull request in github.
9|P A G E
1. Click the Pull Request tab, then from the Pull Request page, click the green New pull request button.
2. Select the branch you made, feature, to compare with master (the original). Look over your changes
in the diffs on the Compare page, make sure theyre what you want to submit
3. When youre satisfied that these are the changes you want to submit, click the big green Create Pull
Request button.
10 | P A G E
4. Give your pull request a title and write a brief description of your changes. When youre done with your
message, click Create pull request!
1. Click the green Merge pull request button to merge the changes into master.
3. Go ahead and delete the branch, since its changes have been incorporated, with the Delete
branch button in the purple box.
11 | P A G E
5.GitHub with Git Comamd-line Tool
Before you can work with Git on the command line, you will need to set some basic configurations:
git status is a command you will use often to verify the current state of your repository and the files it
contains. Right now, we can see that we are on branch master, everything is up to date
with origin/master and our working directory is clean.
12 | P A G E
5.2 Create Local Branches with Git
Now that you have a local copy of the repository, lets use the steps of the GitHub Flow to make a change
in your project. First we will create a branch:
2. Type git status to see that although you created a new branch, you are still checked out
to master (as indicated by the in-line response from Git).
4. Type git status to verify you are now checked out to your new branch.
1. Type git status. Remember that git status allows us to see the status of the files on our branch
at any given time. Your file is listed under the heading Untracked files.
2. Type git add FILE-NAME. This adds the file to the staging area and prepares it to become part
of the next commit.
3. Type git status again to see what has changed. Your file is now listed under the
heading Changes to be committed.
4. Type git commit. This tells git to collect all of the files in the staging area and commit them to
version control as a single unit of work. Git will open your default text editor where you can enter
the commit message.
o The default text editor associated with git is vi in most cases, which requires that you
type :wq to save and quit after entering your commit message.
o Alternatively, you can bypass vi altogether and enter your commit message inline
with git commit -m "your message"
13 | P A G E
5.4 Open a Pull Request on GitHub using Git
Now that you have made some local commits, it is time to send your changes to the remote copy of your
repository on GitHub.com and create a Pull Request:
1. Type git push -u origin BRANCH-NAME to push your commits to the remote, and set a
tracking branch.
4. Fill out the body of the Pull Request with information about the changes youre introducing.
Since this is your repository, you probably dont have anyone to collaborate with (yet). Go ahead and
merge your Pull Request now:
2. Scroll down and click the big green Merge Pull Request button.
14 | P A G E
References
https://guides.github.com/activities/hello-world/
https://try.github.io/levels/1/challenges/1
https://services.github.com/on-demand/
15 | P A G E