Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

github - I mistakenly issued a git branch --set-upsteam-to, what did that do?

I'm trying to get better at using Git. And I'm also starting to get into open-source development. I found an open-source project on GitHub that I thought I'd join. I forked the repo, then cloned it onto my machine. Next I tried to set up my remote to point to the original repo on GitHub so I could fetch/pull from there. But I made a mistake in performing the set-upstream command. I first issued a git remote add upsteam <the Git URL>. Then I fetched upsteam, then issues a git branch --set-upsteam-to=...

Please note, I used upsteam, not upstream.

And yet Git didn't issue any errors. What I realized my mistake, then reissued the commands using upstream. But what in heck did I do to Git and the repo on my machine?

question from:https://stackoverflow.com/questions/65866062/i-mistakenly-issued-a-git-branch-set-upsteam-to-what-did-that-do

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You didn't do anything bad or irreparable.

A remote Git repo has a URL. That's a pain to use, so it's nice to make up a name for it. That name is absolutely arbitrary. Typically we use the name origin for the direct corresponding remote Git repo and the name upstream for the original repo from which our repo is a fork, but you could use heybaburiba and it wouldn't make the slightest difference. It's just a name that you are using as a shorthand.

So if you happen to say

git remote add upsteam <the Git URL> 

you're just assigning that URL an arbitrary name upsteam. That's perfectly fine, and you are then able to say things like git fetch upsteam, git push -u upsteam master, and all other commands that expect the name of a remote.

If you're sorry you said that, delete that remote and create a remote with a different name. It's only a name!

If you're curious about what names you've defined, just say

git remove -v

and you will see a list of names and URLs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...