The basic operation of the local repository connected remote repository 1-

Basic Procedure
  1. First, download and install Git.
  2. Secondly, local public key generated by Git, and adds the public key to GitHub.
  3. Finally, set up a user name and e-mail address of the warehouse personnel
  4. "Git add": Add tracking of files in the current directory.
  5. "Git commit": to submit an updated file to the local repository.
  6. "Git push": the local project submitted to the remote repository GitHub.
  7. In addition to items you need to first download "git clone" project external to the local cloned subsequent use "git pull" GitHub update command to the local pull
Detailed steps Note:
First, install
Github installation
Second, configure Git
1, first create a local ssh key;
Since the transmission between local Git repository and GitHub repository through SSH encryption, so we need to configure the authentication information:
SSH Key generation using the following command:
$ ssh-keygen -t rsa -C "[email protected]"
 
[email protected] mailbox registered on github is behind you, then will be asked to confirm the path and enter your password, we use the default way to enter it on the line. Successful will generate ~ / under .ssh folder, go in, open id_rsa.pub, copy inside the key.
Enter passphrase (empty for no passphrase): The message is to ask for a password, can be empty
 
Successful implementation of the interface shown in Figure:
 

 

Back on github, enter Account Settings (account configuration), the left select SSH Keys, Add SSH Key, title just fill paste in key generated on your computer.
Successfully added interface shown in Figure:
 

 

To verify successful in git bash input:
如果是第一次的会提示是否continue,上面如果有输入密码,会再次提示Enter passphrase for key '/c/Users/Administrator.WIN-QG4MR4EPLKN/.ssh/id_rsa':输入密码。
输入yes就会看到:You've successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。
2、接下来我们要做的就是把本地仓库传到github上去
在此之前还需要设置username和email,因为github每次commit都会记录他们。
$ git config --global user.name "your name" $ git config --global user.email "[email protected]"
新建本地仓库
创建新文件夹,打开,然后执行 git init 以创建新的 git 仓库
成功后如图:

 

新建GitHub仓库
登录在GitHub中,并新建一个仓库

 

 
新建完后会跳转到如下页面

 

 
然后进行远程链接操作, 不然报错:error

 

进入本地仓库后再输入以下命令
$ git remote add origin [email protected]:yourName/yourRepo.git
后面的yourName和yourRepo表示你再github的用户名和刚才新建的仓库

 

加完之后进入.git,打开config,这里会多出一个remote "origin"内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。如下图

 

 

 

 
3. 将本地仓库中的文件上传到GitHub仓库中
先拉取GitHub中的数据,因为GitHub远程仓库中的README.md文件不在本地仓库中时直接push会报错
git pull --rebase origin master
然后再添加信息,直到向GitHub仓库推送新添加的数据
git add [要添加的文件名]
git commit -m [要添加的文件名]
git push -u origin master
 

Guess you like

Origin www.cnblogs.com/TomBombadil/p/11006418.html