On Apr 23, 2009 at 11:34, Juha Heinanen <jh(a)tutpro.com> wrote:
Andrei Pelinescu-Onciul writes:
When updating your local branch (e.g. master)
with the repository
version, please always add --rebase to git pull
(e.g. git pull --ff --rebase origin master).
andrei,
in svn, when i'm at a directory and do 'svn update', it updates that
directory and its sub-directories.
it is hard for me to remember all those arguments that you suggest in
above. so i thought that it would be nice if i had a shell script
git_pull
that would do the same thing as what 'svn update' does. how would that
shell script look like or is it impossible to write one?
#!/bin/sh
git pull --ff --rebase $@
Note that you can use git pull without specifying origin and master and
(e.g. git pull -ff --rebase) and in this case it will use the defaults
from the config files: origin for the repository and whatever you have
in branch.<name>.merge (where <name> is the name of your local branch
you're currently on). If you haven't played with your config the
defaults shold be ok (origin and master), you can check using:
git config --get branch.master.remote
git config --get branch.master.repo
(replace "master" with the name of your local branch if different).
a bash alias for 'git pull' would even be better, but i think bash sucks
big time and does not allow aliases with argument.
Instead of writing a script, you could just configure git to use this
options by default:
git config branch.master.rebase true
git config branch.master.mergeoptions "--ff"
(--ff is even the default, but because of previous gitconfigs that
circulated, some people might have --no-ff).
These config options are per "cloned" repository. If you want to have
them globally, just add --global to git config, e.g.:
git config --global branch.master.rebase true
If you want to have them on by default for all new local branches that
you'll create in the future use:
git config branch.autosetuprebase always # or remote
If you prefer to edit text files rather then running git config, the
files are .git/config (per repository) or ~/.gitconfig (global).
See also
https://sip-router.org/wiki/git/quick-start-guide for some
recommended config options.
Using the options from the command line is a bit safer, since people
might use another git config and the command line overwrites the config
options.
One of the problems with git commands it that there are several ways to
accomplish the same thing. I try to use the most safe version in
examples (safe meaning it doesn't depend on the config or on the current
branch a user might be on), which in general makes them a little longer.
Andrei