a Distributed VCS (Version Control System):
Every local copy contains the whole content of the "central" repository
You can now code in the bus / train / plane / boat
Where other VCS record Deltas to rebuild the complete files, GIT stores snapshots of modified files.
SVN:
Git aims at proposing:
Indeed Git is fast: operations are almost instantaneous
The entire history is accessible offline
Branching is not scary. Actually, branching is the essence of Git. It so easy and flexible that we create several branches every day.
Current version of the file / folder structure + .git directory
Download it from http://git-scm.com/download/win
Add a GUI on top, or use the command line
Add a GUI on top, or use the command line
Use your favorite package installer, or refer to standard git-scm procedure
two ways of doing it
git commit -a
Enter a commit comment
Commit is now in the history
Show the history of a repository
git log
commit fc365c472c195e40d8f4b6278b17a88750e81a92 Author: Baptiste Mesta <baptiste.mesta@gmail.com> Date: Wed Jan 13 16:04:29 2016 +0100 added images commit 5cce7520f99b6a4cba3997cf8f3d275086bef6f0 Author: Baptiste Mesta <baptiste.mesta@gmail.com> Date: Wed Jan 13 16:02:40 2016 +0100 Added slides on git commit commit 58782ccae98c181c68f3297b9d08ae7aed0e2844 Author: Baptiste Mesta <baptiste.mesta@gmail.com> Date: Wed Jan 13 15:13:01 2016 +0100 add section working with git
but having a graphical interface is better...
the staging area is a buffer where you define what will be in the next commit
add a single file
git add myfile.txtadd all files
git add --allbefore adding
$git status on branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: presentation/index.html Untracked files: (use "git add <file>..." to include in what will be committed) presentation/images/staging.png no changes added to commit (use "git add" and/or "git commit -a")
after git add --all
$git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: presentation/images/staging.png modified: presentation/index.html
you can now commit using git commit
A branch is simple pointer to a commit, that is why a branch is git is very light
A branch can be created using git branch branch_name
Then get is usinggit checkout branch_name
When a commit is done on a branch it changes where the branch point to
$ git checkout iss53 $ vim index.html $ git commit -a -m 'add a new footer [issue 53]'
tags are like branch but they do not move
git tag -a "7.2.0"you can merge a branch into an other branch with git merge branch_name
$ git checkout master $ git merge iss53 Auto-merging README Merge made by the 'recursive' strategy. README | 1 + 1 file changed, 1 insertion(+)
rebase is 'moving' a branch and all its commit to an other starting point
$ git checkout experiment $ git rebase master First, rewinding head to replay your work on top of it... Applying: added staged command
The local repository can fetch and push commits to an other repository
these command allow interaction the remote repository
git fetch retrieve changes from a remote repository but do not change the working copyit only update remote branches, e.g. origin/master
git merge without more argument merge the current branch with the branch it tracks
git pull is used more often, it is a shortcut that does git fetch and git merge it can be used with the option --rebase that redo the local commit starting from the new remote position
it often happend to be like this, you made local commit and someone else pushed commit to the remote repository
the git fetch retrieve changes
You can now choose to merge or rebase you local changes
git stash save your local changes without commiting them
git cherry-pick apply a commit on the current branch, can be used to revert commit
git rebase -i rebase a branch interactivly, that allows you to reorder, delete, modify, merge commits
.gitignore file at the root of the working copy to ignore file
GitHub is a Web-based Git repository hosting service
$ git clone git@github.com:bonitasoft/bonita-engine.git
And you're done to get working!
You have the whole copy of the repository, with all the branches, etc. remember?
When you don't have right access to the repository in which you want to make changes
Go to Github and click Fork
You then have a copy of the repo on which you can commit, create branches, and ...
A PR is a request for changes to be applied in a specific branch
You want to change something somewhere in the code. You may not have the rights to commit on this repository You may have the rights to commit but want your changes to be reviewed and commented before applying.
Offers the power of Git in local, whereas your remote repository is SVN