EGit Local vs. Remote repositories

后端 未结 2 907
清酒与你
清酒与你 2021-01-03 11:20

I\'m new to git and am wrapping my head around how I\'m supposed to be using git and egit. From the egit tutorial, I have setup a respository on GitHub, pushed my Eclipse p

相关标签:
2条回答
  • 2021-01-03 11:47

    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.

    0 讨论(0)
  • 2021-01-03 11:51

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

    Branch creation dialog

    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.

    0 讨论(0)
提交回复
热议问题