Git add remote origin u
My view is that with git, this learning curve is absolutely worth it – working with lots of topic branches, merging them easily, and pushing and pulling them about between different repositories is fantastically useful once you become confident with the system. Distributed version control systems such as Git and Mercurial are now so important, and so flexible, that it would be worth teaching courses on them to give people a good grounding.
Git add remote origin u software#
Your remark about a semester course makes me think of something Scott Chacon said in a podcast interview – students are taught about all kinds of basic tools in computer science and software engineering, but very rarely version control. In reply to your comments on one of the other answers, it sounds to me as if are learning about Git in a top-down way very effectively – you’ve discovered that the defaults work, and your question is asking about why ? To be more serious, Git can be used essentially as simply as SVN, but knowing a bit about remotes and branches means you can use it much more flexibly and this can really change the way you work for the better. … to avoid accidentally pushing other branches. Personally, since I tend to have many topic branches (and often several remotes) I always use the form: git push origin master If you just have a branch called master in common between your repository and the remote one, that’ll be the same as pushing your master to the remote master.
master, master:my-experiment, etc.) specified, then Git defaults to pushing every local branch that has the same name as a branch on the remote. If that’s not set up, then origin is used. If no remote is specified, the remote configured for the current branch (in in your case) is used.
Git add remote origin u series#
This is because of a series of difficult-to-remember-but-generally-helpful defaults ? That the username in the scp-style syntax is git is because of the way that GitHub deals with identifying users – essentially that username is ignored, and the user is identified based on the SSH key-pair that they used to authenticate.Īs for the verbosity of git push origin master, you’ve noticed that after the first push, you can then just do git push. The other one, :peter/first_app.git, is one of the different ways of specifying access to a repository over SSH – this is the “scp-style syntax” described in the documentation. The one beginning with git:// is for the Git protocol, which is usually only used for read-only access to repositories. The two URLs that you’ve mentioned indicate that two different transport protocols should be used. git, what else can it be? The git at the beginner seems to be a user account on the Git server? So why does the URL not git:// /peter/first_app.git, but in the other syntax - what syntax is it? Why must it end with. Your summary of what remotes are – like a nickname for the URL of a repository – is correct.
Update: note that the currently accepted answer perpetuates a common misunderstanding about the behaviour of git push, which hasn’t been corrected despite a comment pointing it out. It is not bad to be practical, but probably not practical to the point to not know what is going on. Sometimes it feels like a lot of magic without explanation… and sometimes the person using it is so confident and when asked why, can’t explain it, and respond with something like “that’s the way it is”. Can somebody who knows what is going on give some details?
git, what else can it be? The git in seems to be a user account on the Git server?Īlso, why does it need to be so verbose to use git push origin master? Can’t the default be origin and master? I found that the first time, the origin master is needed, but after a small edit and commit, then git push is all it needs (no need origin master). So why is the URL not git:// /peter/first_app.git, but in the other syntax - what syntax is it? Why must it end with. Searching on the Internet shows that git remote add is to add a “short name”, such as origin, and it can be any name as well, which is like an alias to a URL.Īnd origin is the usual path of where the remote repository points to (in under “Adding Remote Repositories”). Quite often, Git and Ruby on Rails looks like magic… such as in the first chapter of Ruby on Rails 3 Tutorial book, it talks about Git: git remote add origin :peter/first_app.gitĪnd it pretty much says “it just works” without saying too much about what they are and start talking about branching.