Git 操作 GitHub

时间:2023-03-10 00:57:23
Git 操作 GitHub

Git安装 https://www.cnblogs.com/taopanfeng/p/11076702.html

设置用户名(设置一次 以后就不用再设置了)
git config --global user.name 'TaoPanfeng' 设置邮箱(设置一次 以后就不用再设置了)
git config --global user.email '1801957499@qq.com' 查看设置
git config --list 克隆TaoPanfeng的test仓库
git clone https://github.com/TaoPanfeng/test.git 初始化(设置一次 以后就不用再设置了)
git init 查看状态
git status 工作区>>>暂存区
添加/修改文件
单个添加
git add hello.java
批量添加
git add .
删除文件 中括号是文件名 指定文件,不指定则执行所有
git rm [hello.java] 暂存区>>>本地仓库
git commit -m '提交描述' [hello.java] 中括号是文件名 指定文件,不指定则执行所有 diy01为自定义的名称
git remote add diy01 https://github.com/taopanfeng/1.git 本地仓库>>>远程仓库 这里的diy01与上面diy01对应
git push diy01 master 版本查询
多屏显示控制:空格向下翻页. b 向上翻页. q 退出.
git log
git log --oneline
git log --pretty=oneline
git reflog 常用 版本切换
git reset --hard a9d8831 常用
The requested URL returned error:403 Forbidden while accessing

答案:私有项目,没有权限,输入用户名密码,或远程地址采用这种类型:vi .git/config

#将
【remote "origin"】
url=https://github.com/用户名/仓库名.git 修改为:
【remote "origin"】
url=https://用户名:密码@github.com/用户名/仓库名.git

git push错误