使用git hub托管自己的代码

如果想使用git hub托管自己的代码该怎么做呢?

首先要在github上注册一个自己的账号,记住账号和密码。后面推送本地代码的时候会使用到。

注册完之后就可以新建一个仓库

填写仓库的名称、描述等。最后Create respository。这时能够看到我们创建的仓库地址,复制该地址,后面用。

创建完成仓库后,还需要自己用git工具生成本地公钥,然后将公钥写配置到github上。

执行: ssh-keygen -t rsa

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/songchong/.ssh/id_rsa): mm //命名公钥名字
Enter passphrase (empty for no passphrase): //直接空格 代码无密码
Enter same passphrase again:
Your identification has been saved in mm.
Your public key has been saved in mm.pub. //生成公钥mm.pub
The key fingerprint is:
SHA256:0TuWkvSUzeZ+eUsJVKELq7Xq7J74zXHpktZj570HAJ0 songchong@sz-116133
The key's randomart image is:
+---[RSA 2048]----+
|           . . o.|
|         ..+E o  |
|        o +o+o   |
|       . = == .  |
|        S *o.+   |
|         ooo. +..|
|         . o+oo+.|
|        o =++=.o+|
|       .=O.oo.+++|
+----[SHA256]-----+

然后将mm.pub中的内容copy到git hub的settings  -->   中新建一个sshkey即可

那么如何将本地代码push到git hub上呢?

首先在本地创建仓库

  1. git init
  2. git config user.name xxxx
  3. git config user.email [email protected]
  4. git add .
  5. git commit -m "xxxxxx"
  6. git remote add origin https://github.com/songchong11/tiny4412-uboot-2019.git   //将远程仓库地址命名为origin,方便后面使用
  7. git push -u origin master  //将本地master push到远程仓库

这样就创建成功了。

如果需要与人协作开发,只需要将他的xx.pub添加到github中即可。

猜你喜欢

转载自blog.csdn.net/u012830148/article/details/88960532
今日推荐