github使用笔记

参照廖雪峰的git教程。https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

1.安装
sudo apt-get install git

2.登录
git config --global user.name "Your Name"  LightningApple
git config --global user.email "email@example.com"  1000@qq.com(只要是自己的邮箱就可以了)

3.创立仓库
cd “仓库目录”
git init #会生成.git文件

4.提交代码
git add readme.txt
git add ...
git commit -m "message"


5.查看更改记录或当前状态
#代码最后用utf-8格式编码
git status    #查询仓库当前的状态
git diff readme.txt   #查看文件具体修改了什么内容

git log   #查看历史记录
git log --pretty=oneline   #单行历史记录,没有时间

6.版本回退
git reset --hard HEAD^
#HEAD    当前版本
#HEAD^   上一个版本
#HEAD^^  上上个版本
#HEAD~100 往上100个版本
git reset --hard commit_id

git reflog   #记录用户的每一次命令
git diff HEAD -- file   #查看工作区和版本库里面最新版本的区别

7. 文件撤销
git checkout -- file    #让文件回到最近一次git commit或git add时的状态
git reset HEAD file     #把暂存区的修改回退到工作区

8. 版本区的文件删除
git rm file
git commit -m ""

9.提交到github
…or create a new repository on the command line

echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:LightningApple/cs231-ztt.git
#git remote rm origin 删除origin

git push -u origin master

10. git add .    #提交修改或新增的全部文件


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值