Use the easy-setup shell script:
curl -O https://raw.githubusercontent.com/odoo/odoo/master/odoo.py | python2
it will will ask a few questions and create a local copy.
Remotes are "remote repositories" which can be fetched from and pushed
to. Remotes can be listed with git remote
[1] and a local
repository can have any number of remotes. The setup script creates 2 remotes:
odoo
- the official repository and main branches, roughly corresponds to the old "mainline" branches in bazaar. You should never need to push to it, and by default your local copy is configured to forbid it.
odoo-dev
- a grab-bag of development branches, you can push your work to it so other coworkers can work with you.
The working copy and each remote contain multiple branches. Local branches can
be listed by git branch
, remote branches can be listed with git branch
-r
. Both types can be listed with git branch -a
.
Work is only possible on local branches, even though it's possible to check out a remote branch work on it will be lost.
bzr commit
takes all alterations to the working copy and creates a commit
from them. Git has an intermediate step called "staging". git commit
will
create a commit from what has been staged, not from the working copy[2]. Staging is done with git add
. A commit with nothing
staged is a null operation.
Warning
It's possible for a single file to have changes in both the index and working copy: if a file is altered, staged and altered again, the second set of change has to be staged separately
Git has no sequential identifier, each commit is uniquely identified by a SHA
(40 hexadecimal characters) roughly corresponding to a bazaar
revision-id. Providing the full sha is rarely necessary, any unique leading
substring is sufficient, e.g. dae86e
will probably stand in for
dae86e1950b1277e545cee180551750029cfe735
.
- update your remotes with
git fetch --all
- create your development branch with
git checkout -b <branch_name> <source_branch>
. For instance if you wanted to add support for full-text search in master you could usegit checkout -b master-fts-xxx odoo/master
- do your changes, stage them with
git add
and commit them withgit commit
- if your branch is long-lived, you may want to update it to its parent
- update the remotes with
git fetch --all
- merge the remote branch into the local one with
git merge --no-ff odoo/master
- update the remotes with
- to push the branch to the development repository, use
git push -u dev <branchname>
, this will automatically create a branch called<branchname>
on dev. Next time around you do not have to use-u
- once the feature is done, create a pull request
The readme has some instructions.
git log
fulfills the same role as bzr log
and is fairly similar, with
a few differences:
git log
has no-r
argument, its first argument (optional) is a revision specgit log
always operates on ranges, if a single commit is provided (via hash, tag, branch or other) it will list the specified commit and all of its ancestors. To see a single commit, usegit show
.git log
's second positional argument is a path (file or directory). Because both are optional, if both a revision and a file match the revision will be selected. It is recommended to use--
before a file path:git log -- filepath
git log
will actually work if given a directory, instead of pegging the CPU forevergit log
works with removed files or directories without having to provide a revision during which the file or directory still existedgit log
has lots of options to customize the output, e.g.-p
will display the changes to each file[3],--name-status
will list the changed files and how they changed SVN-style (with aM
orD
prefix),--name-only
will just list the changed files,--stat
generates a diffstat view,--grep
filters by grepping on the commit message, …
!DANGER!
Do not use git revert
, it does something completely
different than bzr revert
- If you have altered files which you want to revert, use
git checkout -- <path>
. To revert every file in the directory, usegit checkout -- .
- If you have staged a file and you want to unstage it, use
git reset HEAD <file>
. This will not revert the file's changes, the file will be marked as modified again
git diff
is fairly similar to bzr diff
: it compares the working copy
with stored content and can be restricted to a given file path. However:
git diff
compares the working copy and the staging area, not the latest commitgit diff --staged
compares the staging area and the latest commitgit diff HEAD
ignores the staging area and compares the working copy with the latest commit. More generallygit diff <commit>
will diff the working copy and the specified commit- to diff between commits, simply pass the commit identifiers (no
-r
argument) git diff --stat
provides a diffstat-view of the diff, and can be combined with other flags. It can be used as an intermediate betweengit status
andgit status -s
git checkout
takes an arbitrary commit, the equivalent to bzr update
-r<rev>
is thus git checkout <rev>
.
bzr cat -r<revision> <filename>
shows the file <filename>
as it was at
<revision>
. The Git equivalent is git show <revision>:<filename>
If the last commit has to be fixed a bit (error, missing data,
incomplete/incorrect commit message) it can be fixed with git commit
--amend
. Instead of creating a new commit, it adds whatever is being
committed to the previous commit.
If the last commit has to be removed entirely (similar to bzr uncommit
),
use git reset HEAD~1
.
!DANGER!
do not use this command or the previous one on commits you have already pushed
checkout
, add
, commit
, reset
and stash
can take a -p
flag, which allows operating (staging, reverting, ...) on a subset of the
file. It opens a UI allowing the selection (or not) of each patch hunk, and
even the splitting of hunk if they're too big.
Allows reverting only part of the changes to a file, or cleanly splitting refactorings and fixes mixed in a file.
The default status
command is very verbose (though useful, it provides
instructions for reverting things). The -s
flag provides an SVN-like
display instead with just a listing of files and :abbr:`A (Added)`, :abbr:`M
(Modified)` or :abbr:`D (Deleted)` flags next to them. Each file can have 2
flags, the first is for the index (difference between the last commit and the
index) and the and the second is for the working copy (difference between the
index and the working copy).
checkout -
will behave like cd -
, it will switch to the previously
checked-out branch/commit
[1] | by default, git remote will only give the names of
the various remotes. git remote -v will give the name
and URL of each remote. |
[2] | the -a option will automatically stage modified
and deleted files |
[3] | but only the changes performed by this actual commit, for a merge the merged changes are not considered part of the merge commit |