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).
This will avoid generating confusing useless merge messages (like Merge branch 'master' of ssh://git.sip-router.org/sip-router).
Example:
$ git push origin master:master
To ssh://git.sip-router.org/sip-router ! [rejected] master -> master (non-fast forward) error: failed to push some refs to 'ssh://git.sip-router.org/sip-router'
# failed because the local master branch is not up to date # => update it
$ git pull --ff --rebase origin master
# retry the push
$ git push origin master:master
As an alternative, git can be configured to always rebase when pull-ing on a certain local branch, e.g. for master: git config branch.master.rebase true
See https://sip-router.org/wiki/git/commit-into-master for more detailed info.
Andrei
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?
a bash alias for 'git pull' would even be better, but i think bash sucks big time and does not allow aliases with argument.
-- juha
On Thursday 23 April 2009, Juha Heinanen wrote:
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
Hi Juha,
there exists some frontend for gits, e.g. "eg", "
http://www.gnome.org/~newren/eg/
From the page: Easy Git -- git for mere mortals. eg is biased towards luring existing svn users..
Perhaps you can give this a try?
Henning
Henning Westerholt writes:
there exists some frontend for gits, e.g. "eg", "
http://www.gnome.org/~newren/eg/
From the page: Easy Git -- git for mere mortals. eg is biased towards luring existing svn users..
henning,
eg looks good. especially this page that maps basic svn commands to eg commands:
http://www.gnome.org/~newren/eg/git-for-svn-users.html
-- juha
On Apr 23, 2009 at 11:34, Juha Heinanen jh@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
On Thursday 23 April 2009, Andrei Pelinescu-Onciul wrote:
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).
Hi Andrei,
i've tried your suggestion before commiting:
henning@ca:~/sip-router$ git pull --ff --rebase origin master config.h: needs update [some other files and dirs..] refusing to pull with rebase: your working tree is not up-to-date
Perhaps this only work when i've a complete clean tree?
Cheers,
Henning
On Thursday 23 April 2009, Henning Westerholt wrote:
i've tried your suggestion before commiting:
henning@ca:~/sip-router$ git pull --ff --rebase origin master config.h: needs update [some other files and dirs..] refusing to pull with rebase: your working tree is not up-to-date
Perhaps this only work when i've a complete clean tree?
I've looked earlier in the docs you provided, sorry:
[..] if when trying the rebase you get something like: $ git pull --rebase origin master refusing to pull with rebase: your working tree is not up-to-date
it means you have some uncomitted local changes. Commit them (git add … && git commit) and try again. [..]
So i aparently need to revert all my (not yet ready) changes in order to make this work.
Cheers,
Henning
On Apr 23, 2009 at 13:57, Henning Westerholt henning.westerholt@1und1.de wrote:
On Thursday 23 April 2009, Henning Westerholt wrote:
i've tried your suggestion before commiting:
henning@ca:~/sip-router$ git pull --ff --rebase origin master config.h: needs update [some other files and dirs..] refusing to pull with rebase: your working tree is not up-to-date
Perhaps this only work when i've a complete clean tree?
I've looked earlier in the docs you provided, sorry:
[..] if when trying the rebase you get something like: $ git pull --rebase origin master refusing to pull with rebase: your working tree is not up-to-date
it means you have some uncomitted local changes. Commit them (git add ??? && git commit) and try again. [..]
So i aparently need to revert all my (not yet ready) changes in order to make this work.
You can use git stash to save your not yet commited changes, e.g.:
git stash "my tmp changes"
....
and then you have several options: git stash apply # if everything is ok git stash drop # remove saved stashs # or git stash pop # apply your saved changes and delete them from the stash
or even better and guaranteed conflict free, create a new branch with your stashed stuff:
git stash branch my_tmp_branch
but in general why would you want to update/rebase when you haven't finished your local changes? (it's quite rare that your work-in-progress depends on the latest commit). If you use small commits and different branches for different work (in case that you work on several thing in the same time) it's unlikely that you'll hit this situation too often.
Andrei
On Donnerstag, 23. April 2009, Andrei Pelinescu-Onciul wrote:
You can use git stash to save your not yet commited changes, e.g.:
git stash "my tmp changes"
Hi Andrei,
git stash works fine, now it works with "--rebase".
Henning