How to upload your own code to github

  Steps to upload code to git:


① First register a github account, log in, and create a new repository , click +, click new repository


Get the following page, fill in the warehouse name, write a name by yourself, the following description can be written or not ,

Click Initialize this repository with a README, then create :



②Download git shell. There are many official website download URLs on the Internet. I clicked to download it, but I couldn’t download it.

After I got down, I searched for "git download" on Baidu,

Download can also be used. This is the icon I downloaded:



③Configure Git.

  

 1. Set the local ssh key, open git bash, and enter the command:

ssh-keygen -t rsa -C "[email protected]" where the double quotes are your note

The email address used when registering on github.

   Keep pressing Enter, select the default path, and empty password. Finally, the .ssh folder will be generated in the default path,

Open .ssh and there are two files in it, open id_rsa.pub and copy the key inside.


 

  2. Open github and select settings



Get the following page, click on ssh and gpg keys, and select new ssh key to the right of ssh keys. The content of the green box below appears, fill in the title, and paste the key you just copied into the key. Finally click add ssh key.



3.查看是否成功。在git bash中输入命令:
ssh -T [email protected]
会提示,是否continue,输入yes。后就会看到:
Warning:Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
  Hi zhangsiyao11! You've successfully authenticated, but GitHub does not provide shell access.
这样就成功了,不用理会warning。

4.克隆你刚才新建的仓库到本地,输入命令:
git clone https://github.com/zhangsiyao11/chat
后面的http是你的仓库的地址。

此时会在刚才创建ssh  key的默认目录下生成以你仓库名为文件名的文件,打开得到下图所示:


5.最后将你想要上传的项目文件复制到上面的目录:


6.在此处打开git bash,输入如下命令:
git init
git add "文件名"  
git commit -m "文件名"
如果出现让你设置用户名和用户邮箱的提示,就按照提示上给的命令输入即可。后再次执行上面commit的命令。


git remote add origin https://github.com/zhangsiyao11/chat       http为你自己仓库的地址
如果出现错误:
   fatal: remote origin already exists
则执行以下语句:
git remote rm origin
再执行git remote add origin https://github.com/zhangsiyao11/chat即可。


git pull origin master
git push origin master


完成,再打开自己的仓库就会出现刚刚上传的项目文件:





终于写完了,希望对大家有所帮助。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890979&siteId=291194637