- What are git and github
- How they work
- How can I use them
“Git (/ɡɪt/) is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows.”
“Revision control, also known as version control and source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.”
clear, uh?
Why should I use version control?
“An elegant weapon for a more civilized age.”
Look, it's not useful if I
- Do not have other people working on the code.
- Do not plan on letting others have the code.
- Isn't it an overhead?
Well, have you ever
- made a change to code, realised it was a mistake and wanted to revert back?
- lost code or had a backup that was too old?
- had to maintain multiple versions of a product?
And if you wonder to
- see the difference between two (or more) versions of your code?
- prove that a particular change broke or fixed a piece of code?
- review the history of some code?
Or even
- submit a change to someone else's code?
- share your code, or let other people work on your code?
- see how much work is being done, and where, when and by whom?
And, last but not least
- wanted to experiment with a new feature without interfering with working code?
Desing Goals
- Speed
- Simple Design
- Strong support for thousands of parallel branches
- Fully distributed
- Able to handle larges projects like Linux kernel effectively
- Ensure integrity
Git is a filesystem
Git thinks of its data more like a set of snapshots of a mini filesystem.
Git has integrity
- Everything is checksummed
- References are SHA-1
986da33f0edea8f13b8dee427262ffd1bce0a4c4
Git doesn't delete
- generally only adds data
- if you mess up, you can usually recover your stuff
- not for everyone, though
Three states
- Modified
- Staged
- Committed
- Pushed?
- web-based Git repository hosting service
- offers all of the distributed SCM functionalities of Git
- adds new features
New features
- web-based graphical interface
- desktop & mobile integration
- access control
- pull requests
- and more (wikis, task management, bug tracking, etc.)
Linux
Debian
$ aptitude install git
Ubuntu
$ apt-get install git
Centos
$ yum install git
Arch
$ pacman -S git
OS X
$ brew install git
Also developer tools should be ok...
Identity
$ git config --global user.name "Peter Parker"$ git config --global user.email peterparker@bitmama.it
Editor
$ git config --global core.editor nano
Colors
$ git config --global color.ui true
Configurations are in ~/.gitconfig
Initizialize your project
$ git init
Or clone it
$ git clone https://github.com/andou/github-for-dummies.git
Decide what is relevant
$ git add file1 file2 ...$ git commit
What did I just modify
$ git diff
I've screwed everything up....
$ git reset
sample
.DS_Store*.log/build//doc/[abc]*.txt.sass-cache
- Blank lines or lines starting with # are ignored
- End pattern with slash (/) to specify a directory
- Negate pattern with exclamation point (!)
- Other clones of the same repo
- Can be more than one
- There are default remotes for push and pull
- Github is a remote
$ git remote -vorigin https://github.com/andou/github-for-dummies.git (fetch)origin https://github.com/andou/github-for-dummies.git (push)
Push to remote
$ git push <remote> <branch>
Pull from remote
$ git pull <remote> <branch>
- specify important points in history
- tipically release points
Lightweight tags
$ git tag v0.0.1
Annotated tags
$ git tag -a v0.0.1 -m 'this is my tag'
- are "pointers" to commit
- identify streams of development
- they can diverge from each other
- they can be merged
Merging
- There are different auto-merge strategies
- If it fails, you'll have to fix by hand
- Mark conflicts as resolved and trigger a merge commit
Create new branch
$ git branch iss53
$ git checkout -b iss53 master
Switch Branch
$ git checkout iss53
Delete Branch
$ git branch -d iss53
Move changes to a separate "stash".
$ git stash save$ git stash list$ git stash apply
Legal
License
Attribution
0
Git[hub]
For dummies
Created by Antonio Pastorino / a.pastorino@bitmama.it