|git tip: adding remotes to .git/config
||[Jan. 22nd, 2012|06:33 pm]
Shlomif's Technical Posts Community
|[||Tags|||||git, perl, tech, tech tip, tip||]|
|||||Yehuda Poliker - Hat'halah Hadashah (A New Beginning)||]|
When working with the git version control
system and editing .git/config to add a new remote, some people
may be tempted to copy and change the origin remote that reads
fetch = +refs/heads/*:refs/remotes/origin/*
url = firstname.lastname@example.org:shlomif/perl.git
However, note that origin also appears at the fetch =
and needs to be changed there as well, or else all the branches will be placed
in remotes/origin. Maybe there's a better way to add a new remote
using the git config commands.
Otherwise, I should note that there doesn't seem to be a consensus among
git users whether git pull --rebase is better than a simple
git pull: the perl people told me to use --rebase and the
Amarok people and someone on Freenode's ##programming told
me not to use it. Now I'm just confused.
When you do a git pull and your branch is ahead of origin it'll perform a merge commit (not sure if this is always the case though), otherwise it'll do a fast-forward. If your branch is ahead and you use git pull --rebase then Git won't create a merge commit, but instead pull the changes and rebases your commits on top of it.
If you just don't want to have a merge commit, do "git pull --ff-only", then the merge will only happen if it can resolve as a fast-forward. If it can't, then you can decide what you want to do about it on a case by case basis.
Rebasing is dangerous on a branch that isn't private, that's why people tell you to avoid it: it changes the commit history of the repository, and if you've already pushed that history or had people pull it from you, that can cause a tangled mess that can only be resolved if everyone using that branch coordinate the actions needed in fixing it. (Good luck with that!)
For the OP: for adding remotes, what's wrong with "git remote add upstream " (or some other remote name)?
2012-01-22 08:12 pm (UTC)
rebase or merge
regarding the topic of rebase or merge Linus Torvald has some good explanation and opinion :
http://article.gmane.org/gmane.comp.video.dri.devel/34744 (the entire thread is interesting)
Why would you not use "git remote add foo URL-to-foo" ?
2012-01-27 08:07 am (UTC)
Re: adding remotes
This is a valid approach only I could never remember it, and I've resorted to edit the config file manually out of mental laziness.