Shlomif's Technical Posts Community - git tip: adding remotes to .git/config [entries|archive|friends|userinfo]
Shlomif's Technical Posts Community

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Shlomi Fish's Homepage Main Journal Homesite Blog Planet Linux-IL Amir Aharoni in Unicode open dot dot dot ]

git tip: adding remotes to .git/config [Jan. 22nd, 2012|06:33 pm]
Previous Entry Add to Memories Share Next Entry

shlomif_tech

[shlomif]
[Tags|, , , , ]
[Current Location |Home]
[Current Music |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 something like:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com: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.

LinkReply

Comments:
From: htbaa.myopenid.com
2012-01-22 06:48 pm (UTC)

git pull

(Link)

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.
From: illusori.myopenid.com
2012-01-22 08:29 pm (UTC)

Re: git pull

(Link)

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)?
From: (Anonymous)
2012-01-22 08:12 pm (UTC)

rebase or merge

(Link)

Hi,

regarding the topic of rebase or merge Linus Torvald has some good explanation and opinion :
https://lwn.net/Articles/328436/
http://article.gmane.org/gmane.comp.video.dri.devel/34744 (the entire thread is interesting)

regards
From: Jonathan Duff
2012-01-23 01:26 pm (UTC)

adding remotes

(Link)

Why would you not use "git remote add foo URL-to-foo" ?
From: notbenh.myopenid.com
2012-01-23 05:24 pm (UTC)

Re: adding remotes

(Link)

I had the same question.
[User Picture]From: shlomif
2012-01-27 08:07 am (UTC)

Re: adding remotes

(Link)


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.