Sunny Gupta
Sporty person. Enthusiastic for Digital Devices.
What is Open Source
What is GitHub
What is a Git Repository
What is Forking and Cloning
Setting up Git on your computer
git add, git commit, git push
git fetch, git merge, git branch
Git Workflow
Contribution guidelines
Source Code is available(to mess with)
Generally, available to distribute
may(may not) be free
Why Open Source turned out to be an instant love of every programmer?
I can do what I want.
I am SUPERMAN.
An open source software(application) can be modified according to one's needs
Learn how others are creating that application
Easy to be a part of an ongoing development work
Re-usable code
Generally Free to use
No need to wait for the organization in charge to make changes
Free of any Piracy
Why was it a hassle to contribute into Open Source?
"I am done with all these guys messing up with my code."
Managing code by thousands of contributors was almost impossible.
Following a proper development schedule was not easy.
Hard to find projects of your choice.
...
make your code Open Source
manage literally any number of contributors
manage versions of your product
follow a well defined structure to complete the project
contribute into projects of your choice
find open source projects to work on
create an online portfolio of your skills
To add the functionality you want
To get experience about any technology you have just learnt
To work with people from around the globe
To learn new things
To get a feeling of a significant work
To get known by people in a community
To showcase your skills by working on real-world projects
A GitHub Repository is an online Folder at Github, which contains all of the files within a project.
GitHub allows any contributor to get notified about any changes in any file within a Repository.
A Repository in one account can be copied in another account using "Fork" Button.
A new Repository can be created by clicking on the the "+" button in Github Menu bar.
Vlc - https://github.com/videolan/vlc
Ruby on Rails - https://github.com/rails/rails
facebook-ios-sdk - https://github.com/facebook/facebook-ios-sdk
...
Remote Server(Github)
Local System (Your PC)
Github Profile
Online Repositories
Work Graph
Navigable code
Git bash(terminal)
Local copy of Git Repo
Edit files locally
Working branches
Provides a new "git" command within your Linux terminal or a separate command prompt kind of tool for windows and macs.
Git can be downloaded from: http://git-scm.com/downloads
Linux(Ubuntu): sudo apt-get install git
Windows: http://git-scm.com/download/win
Mac: http://git-scm.com/download/mac
Open up your terminal and set up your user name, as
$ git config --global user.name "YOUR NAME"
Set up your e-mail address(the one you signed up with on github), as
$ git config --global user.email "YOUR EMAIL ADDRESS"
For Further Reference: https://help.github.com/articles/set-up-git
Clones a repo from Remote Server(Github Website) to your local machine(PC).
$ git clone "REPOSITORY CLONE ADDRESS"
For example,
$ git clone https://github.com/smvdu/sfd-smvdu.git
What is Open Source
What is Github
What is a Repository
Forking a Repo
Cloning a Repo
eg. Sublime Text, gedit, vim, notepad, etc.
Shouldmust be present in every github repo
Summary of the project
Basic setup information about the repo
Contribution guidelines
Workflow for this repo
"git status" shows the modified files in cloned copy of repo on the local machine.
$ cd "REPO NAME"
$ git status
on branch master
Files modified:
file1
file2
.
.
"git add" command is used to add modified files for committing.
$ git add --all
This will add all the modified files in the next commit.
Used to ignore the changes in certain files/directories.
"." marks this file as a hidden file.
"git commit" will group together all the changes you have made with a meaningful message.
$ git commit -m "DESCRIPTION ABOUT MODIFICATIONS"
-m stands for commit message
cloned a repo using git clone
made some modifications using a text editor
checked for modified code using git status
finalized files to be committed using git add
committed added files using git commit
README and .gitignore file
Branches in a git repo allows, even further copies of the same code.
Changes done in one branch do not affect the code in another branch, until done explicitly
For any new task, create a new branch and later merge it with the parent branch. In this case new branch is "feature_x" and parent branch is "merge".
To see all the branches in a repo
$ git branch
To create a new branch, from current branch
$ git branch "NEW_BRANCH NAME"
To move to another branch
$ git checkout "BRANCH_NAME"
"git push" sends all the commits to the remote server(Github), from where you cloned your repo.
$ git push "REMOTE NAME" "BRANCH NAME"
$ git push origin master
eg:
Hey(Repo Owner), I have made some changes in this repo, can you add those up with the main repo?
Go to your forked repo on Github
Click on "pull requests" on right hand side of the repo page
Click on "new pull request"
Add the title of the pull request
Send the pull request
Your pull request will be merged by the "Repo Owner" with the parent repo(from where you forked it).
"git fetch" gets the latest code from the parent repo and add it directly to your local repo.
$ git fetch "REMOTE NAME"
$ git merge "REMOTE NAME"/"BRANCH NAME"
Github Remotes are like variables which have the values as the link to a particular repo on Github remote server.
$ git remote add upstream "REPO LINK"
$ git remote add upstream "https://github.com/smvdu/sfd-smvdu.git"
Now anytime when you run "git fetch upstream" it will check your local files against this repo.
"git pull" is similar to "git fetch", but it also runs "git merge" command by itself.
git pull will update all the branches in local repo. Whereas while using git fetch only listed branches will be updated.
$ git pull upstream
"git merge" merges two different copies of code.
Generally used for merging two different branches and code from upstream to local repo.
In branch context,
$ git merge "BRANCH_NAME"
This will add the code from the "BRANCH_NAME" branch to the current branch. Code in any other branch will remain as it is.
If we are on master branch and wants to merge it with develop branch then run,
$ git merge develop
After running "git fetch" command. Fetched code is merged with one of the branches as,
$ git merge "REMOTE NAME"/"LOCAL BRANCH NAME"
for example,
$ git fetch upstream develop
$ git merge upstream/develop
Here, fetch commands gets the code from develop branch of remote server and merges it with current branch.
Arise while using "git merge" command
When git can't decide by itself which code to be preserved
merge conflicts has to be removed by the programmer manually
There shouldn't be any merge conflicts before sending a Pull Request
<<<<<<<< HEAD
def func(a b):
=============
def func(x, y):
>>>>>>> refs/head/new_func
https://guides.github.com/introduction/flow/index.html
Used to define and assign tasks to be completed
Used for any queries regarding the code
Used to report a bug or to give a suggestion
First of all fork the the repo and clone it to your local machine
Run the code on your local machine
Check out the issue page on Github for the repo
Pick up one of the issue and start working on it
Comment below on the issue if there is any doubt
Every good repo on Github has a contribution guidelines link, go through it
Start working on the issue
Create a different branch for every new task
For every small change, create a commit
push the code to your forked repo
From there send a Pull Request to the parent repo
Keep them meaningful, short and to the point.
Create a Repo of your own and run all listed operations on it.
SHOOT YOUR QUESTIONS...
By Sunny Gupta