EGit Local vs. Remote repositories

独自空忆成欢 提交于 2019-11-30 16:02:00
VonC

The "Branching" section of the Egit User Guide can help:

There is no obligation to create a local branch which would be named like a remote tracking branch (see "Having a hard time understanding git-fetch" to have a good understanding of "remote tracing branches).

You can create as many local branches (i.e. branches that you won't necessary push anywhere) as you want/need.

But if you don"t see any remote branch, maybe you didn't fetch that GitHub repo in the first place: see Fetching.

Since you created the repo on your local system and then pushed it to github without creating a remote you don't have a remote at hand. A remote is simply a short alias for the remote repository's URL. To fix this create a remote and a push and fetch configuration from the repositories view. In order to populate remote tracking branches in your local repo you need to run fetch once. As soon as this is done you can use "Push to upstream" instead of the more complex Team > Push... dialog which allows to define all parameters on the fly. When using native git command line you'll find the same concepts implemented there:

with "$ git push [url] [refspec]" (e.g. "$ git push https://github/user/myrepo.git master:master") you pass all parameters explicitly, this is similar to Team > Push... in EGit

with "$ git push [remote]" (e.g. "$ git push origin") you push to the repository defined by the configuration parameters of the given remote (check .git/config to see these parameters or open repository configuration from egit preference in Eclipse), this is similar to Team > Push to upstream in EGit. Usually the refspec used in this way is implicitly configured when creating a local branch based on a remote tracking branch. It's also possible to add this configuration later but since this is more tedious manual configuration the other way is more handy.

If you clone a remote repository the repository you cloned from is stored as remote "origin" in your clone. This way you can skip configuring the remote manually. This is only needed if the repository is born when you create it from scratch.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!