git commands - add a remote repository

git commands - add a remote repository

  1. First created on GitHub your own remote repository: For example, I created a remote repository mybatisfor me recently saved mybatis code is

    present, this learngit repository on GitHub empty, GitHub tell us, you can clone from this new warehouse warehouse, can also associated with an existing local warehouse, then the contents of the local repository pushed to GitHub repository.

  2. The content pushed to the remote repository: You can use this command only after the premise is that you have the file and add the staging area file commit to your local repository git push -u origin master

    of the directive probably means: the contents of the local repository pushed to the remote, use git push command actually the current push to the remote master branch.

    Because the remote library is empty, the first time we push the master branch, coupled with the -u parameter, Git will not only master the new remote branch content push local master branch, but also the local master branch and remote associated master branch, after the push or pull upon the command can be simplified.
  3. So far, the operation has been completed git from zero to one. If these files or so later so that the local repository has been added after the new, post-viewing operation using git status, add and re-commit to the local repository, do not have to repeat the procedure. Directly to git push origin masterthe latest modification of the local master branch pushed to GitHub.

ps:


When you create a remote repository, there are two options, one is a ssh is https, use https when safer, particularly when used in each submission will need to enter a user name and password before they can submit up, but because it is stored locally ssh keys, direct eh skip this step.

When you first use the clone Git commands or push connection GitHub, you will get a warning:

The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?

This is because Git uses SSH connection, and when the first SSH connection verification Key GitHub server, you need to confirm whether the fingerprint information Key's GitHub GitHub really from the server, enter yes press Enter.

Git会输出一个警告,告诉你已经把GitHub的Key添加到本机的一个信任列表里了:

Warning: Permanently added 'github.com' (RSA) to the list of known hosts.

summary:

要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git;

关联后,使用命令git push -u origin master第一次推送master分支的所有内容;

此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改;

分布式版本系统的最大好处之一是在本地工作完全不需要考虑远程库的存在,也就是有没有联网都可以正常工作,而SVN在没有联网的时候是拒绝干活的!当有网络的时候,再把本地提交推送一下就完成了同步,真是太方便了!

Guess you like

Origin www.cnblogs.com/chenyameng/p/11366788.html