Reminders versionning ecosystem
Approval %
- svn
- bazaar
- git
- mercurial
- ...
Works locally, allow to push on anyone's repository
Allow offline work but requires the developer to
A commit is represented with a sha1 hash.
Where we create files, but they are not linked to the repository in any way.
We add files to an index, so now they are tracked.
git init
git add file.txt
git commit -m "Initial commit"
Introduction of HEAD
: HEAD
is a link to a sha1 hash (commit).
git add file2.txt file3.txt
git commit -m "Added file2 file3"
HEAD
moved to the new commit number.
echo "test" >> file2.txt
git commit -a -m "message"
Branching:
git branch myidea
The branch is created but the HEAD
is still on the master branch.
git checkout myidea
Move the HEAD
to the myidea branch.
echo "test" >> file3.txt
git commit -a -m "message"
Moving back to master
git checkout master
The HEAD is back on the top of master, so does not contains the edit of the file3.txt done on the myidea branch.
git merge myidea
This creates a new commit on the current branch (master
) that contains the commits from the myidea
branch.
Explanation of merging master on a feature branch.
git checkout myidea
The HEAD
is back on the commit 4.
Once the feature is finished, we can delete the feature branch:
git branch -d myidea
Clone a repository. You get a master
branch as the repository, but also an origin/master
.
When a dev adds 2 commits, and we do add 2 commits too.
origin
(the default naming convention for the remote branch)
git fetch origin
Fetches the state of the remote (so the branch origin/master
gets the 2 new commit from the other developers.
git status
will inform you of the differences
git merge origin master
git push origin master
No one on master (deployable branch, can be deployed at anytime)
A development
branch usually receive the developers commit. Developers work on feature branches and then merge back to development.
Warning: be careful, do it only on your own branch.
--amend
rebase
Interactively move the HEAD
back and forth, asking for each move whether you still have the bug.
Interactive tutorial from Github and Codeschool
- Commit message should be meaningful
- Having lots of small commits is better than on massive one, as it allows to revert a single commit, whereas you probably would not revert a massive commit.