Git is
a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.The main repository of the
MicroLua project is hosted here at
GoogleCode and is a Subversion one, but Git has a special subset of commands providing
bidirectional operation between a Subversion repository and git:
git-svn.
This page will give you the basic commands to interact with our repository. If you want to use Git with a graphical interface, have a look at
HowToUseGitGui.
The best way to use Git on Windows seems to install
msysgit, which has a command line interface.
For each git-svn command used here, you can refer to
the official documentation.
cd /where/I/usually/work/with/microlua
mkdir my_working_copy # or anything else
cd my_working_copy
git svn clone http://microlua.googlecode.com/svn/ .
# or better if you have the `Commit` permission
git svn clone https://microlua.googlecode.com/svn/ .
# wait for the repository and the code to be downloaded
cd /where/I/usually/work/with/microlua
mkdir my_working_copy # or anything else
cd my_working_copy
git svn clone
http://microlua.googlecode.com/svn/ .
# or better if you have the
Commit
Commit
permission
git svn clone https://microlua.googlecode.com/svn/ .
# wait for the repository and the code to be downloaded
}}}
Waiting can be a bit long because you are downloading the whole history, not just the most recent version.
== Fetch the newest version ==
{{{
cd my_working_copy
git svn fetch
# wait a bit for the code to be updated in the remotes/git-svn branch
}}}
Now your
permission
git svn clone
https://microlua.googlecode.com/svn/ .
# wait for the repository and the code to be downloaded
}}}
Waiting can be a bit long because you are downloading the whole history, not just the most recent version.
cd my_working_copy
git svn fetch
# wait a bit for the code to be updated in the remotes/git-svn branch
cd my_working_copy
git svn fetch
# wait a bit for the code to be updated in the remotes/git-svn branch
}}}
Now your
master
master
branch needs to be _fast-forwarded_.
{{{
git checkout master
git merge remotes/git-svn
}}}
Because you changed nothing in the
branch needs to be
fast-forwarded.
git checkout master
git merge remotes/git-svn
git checkout master
git merge remotes/git-svn
}}}
Because you changed nothing in the
master
master
branch of your working copy, you should not end with conflicts (see the [#Make_changes make changes section]). The merge should be a _fast-forward_ one.
Note that you can do this two steps in one with
branch of your working copy, you should not end with conflicts (see the [#Make_changes make changes section]). The merge should be a
fast-forward one.
Note that you can do this two steps in one with
git svn rebase
git svn rebase
(you must be in the
(you must be in the
master
master
branch):
{{{
cd my_working_copy
git checkout master
git svn rebase
}}}
== Make changes ==
You should never make changes to the
branch):
cd my_working_copy
git checkout master
git svn rebase
cd my_working_copy
git checkout master
git svn rebase
}}}
You should never make changes to the
master
master
branch. As usual with git, create a topic branch with [http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html git checkout] (which is more convenient than a
branch. As usual with git, create a topic branch with
git checkout (which is more convenient than a
git branch faster_wifi
git branch faster_wifi
and then a
and then a
git checkout faster_wifi
git checkout faster_wifi
):
{{{
git checkout -b faster_wifi
}}}
Edit the code as you usually do, test it.
=== See what changed ===
To see what files were changed, use [http://www.kernel.org/pub/software/scm/git/docs/git-status.html git status]:
{{{
cd my_working_copy
git status # shortcut: git st...
}}}
To see what changed in the files, use [http://www.kernel.org/pub/software/scm/git/docs/git-diff.html git diff]:
{{{
cd my_working_copy
git diff
}}}
To see what changed in a particular file:
{{{
cd my_working_copy
git diff path/to/the/file
}}}
=== Write a patch ===
If you don't have commit access, you can publish your changes pasting a patch somewhere or attaching a patch to an issue.
{{{
cd my_working_copy
git diff (path/to/the/file) > path/where/to/store/the/patch/reason_for_the_changes.diff
}}}
With Git, you can [#Commit_locally store this set of changes locally] to be able to work on another set of changes with a clean state to begin with.
=== Commit locally ===
Git is superior to Subversion here as you can commit locally to store and organize your changes. Maybe you will publish them, maybe not. In any case, please read the CommitMessage page.
So this is all about [http://www.kernel.org/pub/software/scm/git/docs/git-add.html git-add], [http://www.kernel.org/pub/software/scm/git/docs/git-diff.html git diff --cached] and [http://www.kernel.org/pub/software/scm/git/docs/git-commit.html git-commit], but remember to always commit in another branch than
):
git checkout -b faster_wifi
git checkout -b faster_wifi
}}}
Edit the code as you usually do, test it.
To see what files were changed, use
git status:
cd my_working_copy
git status # shortcut: git st...
cd my_working_copy
git status # shortcut: git st...
}}}
To see what changed in the files, use
git diff:
cd my_working_copy
git diff
cd my_working_copy
git diff
}}}
To see what changed in a particular file:
cd my_working_copy
git diff path/to/the/file
cd my_working_copy
git diff path/to/the/file
}}}
If you don't have commit access, you can publish your changes pasting a patch somewhere or attaching a patch to an issue.
cd my_working_copy
git diff (path/to/the/file) > path/where/to/store/the/patch/reason_for_the_changes.diff
cd my_working_copy
git diff (path/to/the/file) > path/where/to/store/the/patch/reason_for_the_changes.diff
}}}
With Git, you can [#Commit_locally store this set of changes locally] to be able to work on another set of changes with a clean state to begin with.
Git is superior to Subversion here as you can commit locally to store and organize your changes. Maybe you will publish them, maybe not. In any case, please read the
CommitMessage page.
So this is all about
git-add,
git diff --cached and
git-commit, but remember to always commit in another branch than
master
master
. You will find thousand of tutorials about this process.
=== Commit to the central repository ===
To see what you are about to commit, try
{{{
git log remotes/git-svn..HEAD
}}}
or
{{{
git svn dcommit -n
}}}
If you are happy with what
. You will find thousand of tutorials about this process.
To see what you are about to commit, try
git log remotes/git-svn..HEAD
git log remotes/git-svn..HEAD
}}}
or
git svn dcommit -n
git svn dcommit -n
}}}
If you are happy with what
git
git
answers, you can use
answers, you can use
git svn dcommit
git svn dcommit
.
You'll need the Commit permission, ask Grahack if you want it. Please be sure to have read the CommitMessage page.
*NOTE*: Even if you have the Commit permission and typed the right password, you won't be able to authenticate if you checked out from
.
You'll need the Commit permission, ask Grahack if you want it. Please be sure to have read the
CommitMessage page.
NOTE: Even if you have the Commit permission and typed the right password, you won't be able to authenticate if you checked out from
http
http
and not
and not
https
https
.
*NOTE 2*: If you use msysgit, you might have troubles with
.
NOTE 2: If you use msysgit, you might have troubles with
dcommit
dcommit
:
{{{
could not decode commit messages as UTF-8
}}}
By default, Git considers commit messages are encoded in UTF-8, but msysgit seems to encode in ISO-8859-1 (according to what happend on a French Windows version). You can fix this by setting
:
could not decode commit messages as UTF-8
could not decode commit messages as UTF-8
}}}
By default, Git considers commit messages are encoded in UTF-8, but msysgit seems to encode in ISO-8859-1 (according to what happend on a French Windows version). You can fix this by setting
i18n.commitencoding
i18n.commitencoding
to the correct encoding (here ISO-8859-1):
{{{
git config i18n.commitencoding ISO-8859-1
}}}
=== Publish a branch ===
There are several ways to publish a branch. You can use [http://github.com/ Github] or [http://gitorious.com/ Gitorious] to host a Git repository, or upload a repo to a personal server.
The latter can be done like this:
{{{
# in your local repo
git clone /path/to/the/repo/to/clone --bare microlua.git
scp -r microlua.git me@ssh.example.com:/path/to/exposed/space/for/repositories
# on the server example.com
cd /path/to/exposed/space/for/repositories
chmod +x microlua.git/hooks/post-update
cd microlua.git
git-update-server-info
# then you can be cloned/tracked with something like
git clone http://example.com/repositories/microlua.git/
}}}
=== Update changes to upstream source ===
You can resync your topic branch with
{{{
git checkout faster_wifi
git svn rebase
}}}
It will fetch the latest history in the remote repository and move your branch on top of the latest available code (
to the correct encoding (here ISO-8859-1):
git config i18n.commitencoding ISO-8859-1
git config i18n.commitencoding ISO-8859-1
}}}
There are several ways to publish a branch. You can use
Github or
Gitorious to host a Git repository, or upload a repo to a personal server.
The latter can be done like this:
# in your local repo
git clone /path/to/the/repo/to/clone --bare microlua.git
scp -r microlua.git me@ssh.example.com:/path/to/exposed/space/for/repositories
# on the server example.com
cd /path/to/exposed/space/for/repositories
chmod +x microlua.git/hooks/post-update
cd microlua.git
git-update-server-info
# then you can be cloned/tracked with something like
git clone http://example.com/repositories/microlua.git/
# in your local repo
git clone /path/to/the/repo/to/clone --bare microlua.git
scp -r microlua.git me@ssh.example.com:/path/to/exposed/space/for/repositories
# on the server example.com
cd /path/to/exposed/space/for/repositories
chmod +x microlua.git/hooks/post-update
cd microlua.git
git-update-server-info
# then you can be cloned/tracked with something like
git clone
http://example.com/repositories/microlua.git/
}}}
You can resync your topic branch with
git checkout faster_wifi
git svn rebase
git checkout faster_wifi
git svn rebase
}}}
It will fetch the latest history in the remote repository and move your branch on top of the latest available code (
remotes/git-svn
remotes/git-svn
).
Beware not to change already published branches though.
== Track someone's code ==
=== Instructions ===
To bind a remote repository to one of your tracking branches, use the
[http://www.kernel.org/pub/software/scm/git/docs/git-remote.html git remote]
set of commands.
{{{
# bind
git remote add grahack http://baco.myftp.org/repositories/microlua.git
# you have to request an update if you didn't add
).
Beware not to change already published branches though.
To bind a remote repository to one of your tracking branches, use the
git remote
set of commands.
# bind
git remote add grahack http://baco.myftp.org/repositories/microlua.git
# you have to request an update if you didn't add `-f` to the previous command
git fetch grahack
# now git branch -a should show you the remotes bound to Grahack's repo:
git branch -a
#* master
# remotes/git-svn
# remotes/grahack/constants
# remotes/grahack/master
# remotes/grahack/pixel
# bind
git remote add grahack
http://baco.myftp.org/repositories/microlua.git
# you have to request an update if you didn't add
-f
-f
to the previous command
git fetch grahack
# now git branch -a should show you the remotes bound to Grahack's repo:
git branch -a
#* master
# remotes/git-svn
# remotes/grahack/constants
# remotes/grahack/master
# remotes/grahack/pixel
}}}
If you just plan to have a quick look and not change some of the tracked code:
{{{
git checkout remotes/grahack/constants
}}}
Or you may want to create a local tracking branch:
{{{
git checkout --track -b remotes/grahack/constants
}}}
Now to update your favorite remote:
{{{
git fetch grahack
}}}
=== URLs of some repositories ===
* Grahack:
to the previous command
git fetch grahack
# now git branch -a should show you the remotes bound to Grahack's repo:
git branch -a
#
master
# remotes/git-svn
# remotes/grahack/constants
# remotes/grahack/master
# remotes/grahack/pixel
}}}
If you just plan to have a quick look and not change some of the tracked code:
git checkout remotes/grahack/constants
git checkout remotes/grahack/constants
}}}
Or you may want to create a local tracking branch:
git checkout --track -b remotes/grahack/constants
git checkout --track -b remotes/grahack/constants
}}}
Now to update your favorite remote:
git fetch grahack
git fetch grahack
}}}* Grahack: http://baco.myftp.org/repositories/microlua.git
http://baco.myftp.org/repositories/microlua.git
* !PapyMouge:
* PapyMouge: git://papymouge.indefero.net/papymouge/microlua.git
git://papymouge.indefero.net/papymouge/microlua.git