1.git
管理代码的工具
2.安装git
sudo apt install git
git --version
3.配置git
指定你的名字
git config --global user.name 你的名字
指定邮箱
git config --global user.email 你的邮箱
4.git工作过程
先从工作区add到暂存区,再从暂存区commit到分支
默认有主分支master
5.添加到暂存区的命令
git add 文件名
6.提交到分支的命令
git commit -m 备注信息
7.查看状态
git status
------------------------------
1.GitHub
远程代码托管的网站
1.打开github的官网,注册一个账号
2.右上角有一个头像的图标,这个图标里有一个setting的选项
点开选项左边有一个SSH and GpG的按钮
点击按钮打开页面里边有new ssh key的按钮。点击添加
3.在linux终端中输入生成秘钥和公钥的命令
ssh-keygen -t rsa -C 你的邮箱地址
一路回车直到出现一堆文字
4.在用户目录下有一个.ssh文件夹里有id_rsa.pub的文件
5.通过cat命令查看文件的内容
6.将文件的内容复制到github网页的key选项框里
7.给title起个名字
8.点击addsshkey添加按钮
---------在github上创建远程的项目(仓库)----------
1.点击右上角加号按钮第一个选项
2.给仓库起名字。
点击readme选项(可选操作)
3.点击crete按钮创建即可
------------将github上的远程项目克隆到本地----------------
1.克隆命令(仓库或工作区)
git clone 写github上创建的项目的地址
-----------关联--------
1.git remote add origin 写远程项目的地址(网址)
------
1.可以在本地仓仓库做一些添加上传的操作
2.上传到远程
git push -u origin master
例如:(在复制远程仓库中操作)
git@iZ2ze4p7rlsw8n0m6qmrzzZ:~/project/bank$ git add 银行系统存储
git@iZ2ze4p7rlsw8n0m6qmrzzZ:~/project/bank$ git status
git@iZ2ze4p7rlsw8n0m6qmrzzZ:~/project/bank$ git commit -m 'bank'
git@iZ2ze4p7rlsw8n0m6qmrzzZ:~/project/bank$ git push -u origin master
Username for 'https://github.com': feiYufy123
Password for 'https://feiYufy123@github.com':
ssh-keygen 命令中间没有空格,如果在ssh后面加上空格,会得到Bad escape character ‘ygen’.的错误
提示出错信息:fatal: remote origin already exists.
解决办法:
git remote rm origin
GitHub的使用
最新推荐文章于 2024-07-19 23:15:00 发布