0% found this document useful (0 votes)
4 views

Git GitHub

The document discusses the advantages and functionalities of Git, an open-source distributed version control system, emphasizing its efficiency and local operations. It provides a comprehensive overview of Git commands for creating repositories, committing changes, branching, merging, and collaborating with others using GitHub. Additionally, it highlights GitHub features such as Markdown for documentation and service hooks for automation.

Uploaded by

Abdelhak Zaim
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Git GitHub

The document discusses the advantages and functionalities of Git, an open-source distributed version control system, emphasizing its efficiency and local operations. It provides a comprehensive overview of Git commands for creating repositories, committing changes, branching, merging, and collaborating with others using GitHub. Additionally, it highlights GitHub features such as Markdown for documentation and service hooks for automation.

Uploaded by

Abdelhak Zaim
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

Workflow

an opinionated discussion

Shreyas
some slides adopted from and inspired by Scott Schacon’s
Grad Student, MIMS’14 seekshreyas
https://github.com/schacon/git-presentations
We’ve all been here ...
We’ve all been here ...
We’ve all been here ...
Problems

• multiple versions
conflicts
• many contributors

• ...
git + Github
a better workflow
git

git is an open source,


distributed version control
system designed for speed
and efficiency
git

git is an open source,


distributed version control
system designed for speed
and efficiency
git

git is an open source,


distributed version control
system designed for speed
and efficiency
git

git is an open source,


distributed version control
system designed for speed
and efficiency

(almost) everything is local


No Network needed for

• Performing a diff

• Viewing file history

• Committing changes

• Merging branches

• Obtaining any other revision of a


file

• Switching branches (almost) everything is local


git

git is an open source,


distributed version control
system designed for speed
and efficiency

More Advantages
tp://bit.ly/git-advantages http://bit.ly/git-linus-intro
.. and

• No .svn directories

• Independence
installing git
http://git-scm.com/downloads
getting setup ...

$ git config --global user.name


“<YOUR_NAME>”
$ git config --global user.email
“<YOUR_EMAIL>”

or edit them in ~/.gitconfig


lets dive in..
gitref.org/

• Creating New Repo

• Committing

• Branching/Merging

• InspectionCloning a
RepoUpdating
lets dive in..
http://git-scm.com/docs

• Creating New Repo

• Committing

• Branching/Merging

• Inspection

• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo $ git init
• Committing $ mkdir workspace

• Branching/ $ cd workspace
Merging $ ls -al
Initialized empty Git repository in
$ git init
• Inspection ../workspace/.git/
drwxr-xr-x 10 Shreyas staff 340 Jan 15
$ ls -al
17:22 .git
• Cloning a Repo

• Updating
Git Commands
$ cd .git
• Creating New $ tree -a
Repo

• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
Git Commands
$ cd ..
$ touch testfile.md
• Creating New
Repo

• Committing
$ git status
• Branching/
Merging
branch
• Inspection name
staging
• Cloning a Repo area

• Updating
Git Commands
• Creating New
$ git add
Repo
<filename>
$ git status
• Committing

• Branching/
Merging

• Inspection staging
area
• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo $ git commit
$ git status
• Committing

your commit
• Branching/
msg
Merging

• Inspection

• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo $ git reset
(undo add)
• Committing

• Branching/ changes staged


Merging

• Inspection

• Cloning a Repo changes


unstaged
• Updating
Git Commands
• Creating New
$ git reset --soft
Repo
HEAD^ (undo a commit and
redo)

$ git reset --hard


• Committing

• Branching/
Merging
HEAD~3
Rewind the branch to get rid of last three
commits
• Updating

• Inspection learn more here : http://git-scm.com/docs/git-


reset
• Cloning A Repo also refer
git revert : http://git-scm.com/docs/git-re
vert.html
git stash : http://git-scm.com/docs/git-st
ash
Git Commands
• Creating New
Repo $ git rm <filename> remove a file from
as expected, you will need tothe repo
commit
• Committing
the change
• Branching/

$ git mv <filename>
Merging

• Inspection move/rename a file from the repo


as expected, you will need to commit
• Cloning a Repo the change

• Updating
Git Commands
• Creating New
Repo $ git branch list of
branches

• Committing
$ git branch
new branch
<branchname>
Branching/
$ git checkout

Merging
switch
• Inspection
<branchname>
• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo branch list
new branch
• Committing dev

• Branching/ switch
Merging branch

• Inspection

• Cloning a Repo

• Updating
Git Commands
• Creating New
$ git merge merge

<branchname>
Repo branches

• Committing

• Branching/
Merging

• Inspection

branch merge
• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo
$ git log
• Committing
--graph text-based graph :)

• Branching/
--decorate
Merging
--abbrev-
• Inspection commit
• Cloning a Repo --all
• Updating --pretty=oneline
Git Commands
• Creating New
Repo
~/.gitconfig
• Committing
[alias]
• Branching/
l = log --pretty=oneline -n 20 --
Merging graph
• Inspection

• Cloning a Repo

• Updating
Git Commands
• Creating New
Repo
$ gitk
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
Working with others...
• Creating New
Repo
github
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
create an account
www.github.com/edu
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
add ssh key
www.github.com/edu
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
$ git clone <url>
• Committing <name>https://github.com/jblomo/
datamining290

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
Fork a repo
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
$ git pull = git fetch + git merge

• Committing $ git push


• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub
• Creating New
Repo
GitHub Pull Request
• Committing

• Branching/
Merging

• Inspection

• Cloning a Repo

• Updating
GitHub Ninja Features

Markdown for documentation

Pages for project hosting

Gist for project hosting

Service Hooks ‘do something’ on commit


may the Force be with
you

You might also like