Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
The slide contains Git workflow, command line instructions to work with Git, examples of project management over GitHub.
Breaking the Kubernetes Kill Chain: Host Path Mount
Introduction to Git and Github
1. INTRODUCTION TO GIT AND GITHUB
ATIQUE AHMED ZIAD
LEAD DEVELOPER, LEGALX LTD.
MOZILLA REPRESENTATIVE
2. LET’S DISCUSS SOME ISSUES…
Can not work parallelly.
No version controlling.
Wrestling with bugs.
Revision is not made easy.
3. WHAT IS GIT AND GITHUB
“Git is a free and open source distributed version control system
designed to handle everything from small to very large projects
with speed and efficiency.”
“GitHub is a cloud based platform built around the Git tool. It is an
online service that stores code pushed to it from computers
running the Git tool. It offers all of the distributed version control
and source code management functionality of Git as well as adding
its own features.”
4. A SHORT STORY OF GIT
In 2002, the Linux kernel project began using a proprietary DVCS
called BitKeeper
In 2005, BitKeeper’s free-of-charge status was revoked.
This prompted the Linux development community (and in
particular Linus Torvalds, the creator of Linux) to develop their
own tool.
This gave birth to Git in 2005. It’s amazingly fast, very efficient
with large projects, and it has an incredible branching system for
non-linear development
5. INSTALLATION OF GIT
Download Git from https://git-scm.com/downloads
Downloaded ? Time to install it !
Verify Git installation.
Git Config
Username config:
Email config:
$ git config --global user.name yourusername
$ git config --global user.email youremail@example.com
$ git
6. MAKE YOUR FIRST REPOSITORY IN GITHUB
Open a new repository in Github.
Choose / create a directory with some files inside it.
Follow the below commands in Terminal / CMD:
This will initialize Git in the directory. A folder named .git has been
created.
The git status command displays the state of the working directory and
the staging area.
$ git init
$ git status
7. MAKE YOUR FIRST REPOSITORY IN GITHUB
$ git add .
$ git commit –m “commit title”
$ git remote add origin <REMOTE_URL>
$ git push –u origin master
Git add all files
Commit the added files
Set remote repository url (if not set previously)
Push to remote repository
Checkout remote urls
$ git remote -v
11. GIT COMMIT
• A commit in a git repository records a snapshot of all the
files in your directory. It's like a giant copy and paste, but
even better!
• A commit takes all staged changes into it.
$ git commit –m “commit title”
12. VIEWING COMMIT HISTORY
$ git log
VIEW LOG WITH PATCH AND LAST ENTRIES
$ git log –p -1
-p stands for patch which shows the differences in each commit
-1 used for showing only last one commit
13. POINTER & HEAD
When you make a commit, Git stores a commit object that contains a pointer
to the snapshot of the content you staged.
How does Git know what branch you’re currently on? It keeps a special pointer
called HEAD.
14. GIT BRANCHES
Branching means you diverge from the main line of development
and continue to do work without messing with that main line.
• Branches in git are incredibly lightweight.
• They are simply pointers to a specific commit -- nothing more.
• “Killer Feature” of git.
15. GIT CREATING NEW BRANCH
$ git branch <branch_name>
Here the new branch name is testing
16. GIT BRANCHES COMMANDS
$ git checkout –b <branch_name>
Opening a new branch and switching to that branch
$ git checkout –d <branch_name>
Deleting a local branch
$ git push <remote_name> –d <branch_name>
Deleting a remote branch
$ git checkout <branch_name>
Switching to a branch
$ git branch
See all branches
19. GIT MERGE CONFLICT
When two people edit the same line having different branch with
different commit history.
If c3 and c4 commit edit the same line & we want to merge iss53
branch into master branch, then the conflict happens.
20. GIT FORK AND CLONE
$ git clone REMOTE_URL
NOTE: It sets the remote repository URL while performing git clone command.
21. PULL REQUEST
• Pull request is created by comparing changes in branches.
• Once a pull request is sent, interested parties can review the set
of changes, discuss potential modifications, and even push
follow-up commits if necessary
ISSUES
• Issues are a great way to keep track of tasks.
• Issues can act as more than just a place to report software bugs.
22. ADD-ONS MOZILLA GITHUB REPOSITORY
Open source, where anyone can contribute code
How can one contribute code:
Fix any mentioned issue in your forked repository
and send a pull request
https://github.com/mozilla/addons-server
23. HOW WILL YOU COLLABORATIVELY
WORK ON YOUR PROJECT
Break each features into small piece of work and write them as
issues in GitHub.
Everytime you work on an issue, you open a new branch and
make a patch on that branch for the issue.
When you make the patch, send a pull request to master branch
from that branch (that branch where you have made the patch
that fixes the issue)