github使用记录

推荐学习链接:https://www.liaoxuefeng.com/wiki/896043488029600/896827951938304


1. 在本地创建ssh key

  • $ ssh-keygen -t rsa -C “[email protected]
  • 打开:C:\Users\dnxl.ssh\id_rsa.pub并复制;在github中点击头像,settings->ssh添加ssh key

2.连接github并登陆

3.克隆远程仓库到本地库

  • $ cd /D
  • $ git clone https://github.com/dnxl205/super-spork.git

4.将文件复制到本地库,上传提交

  • $ cd /D/super-spork
  • $ ls
  • $ git add test.txt
  • $ git commit -m “my first git test”
  • $ git push origin -u master //将master分支推送到远程(-u 在后续提交指令中可以简化)

其他Git指令

  • $ pwd //显示当前目录
  • $ ls //显示当前目录下的文件
  • $ rm //本地删除文件
  • $ git rm //版本库中删除文件
  • $ git status //显示工作区状态、哪些文件被修改
  • $ git diff //查看工作区文件具体修改的内容
  • $ git diff HEAD – //查看该文件工作区、版本库
  • $ git log //显示日志
  • $ git reset --hard HEAD^ //回退一个版本,两个版本:HEAD^^,多个版本HEAD~5
  • $ git reset --hard 1094a //回退到指定版本号
  • $ git reflog //查看历史命令
  • $ git checkout – //丢弃工作区的修改,版本和master或stage一样
  • $ git reset HEAD //文件从暂存区撤回到工作区
  • $ git swich -c dev //创建并切换到dev分支
  • $ git branch -D dev //销毁某分支
  • $ git swich master //切换到master分支
  • $ git branch //查看分支
  • $ git merge //合并某分支到当前分支
  • $ git merge --no–ff -m “分支注释信息” dev //使用普通模式合并分支,保留分支历史信息
  • $ git stash //冻结当前工作现场
  • $ git stash list //查看冻结列表
  • $ git stash pop //恢复冻结的工作现场
  • $ git cherry-pick 4c805e2 //复制一个特定的提交到当前分支
  • $ git tag v1.0 //在当前分支上打标签
  • 工作区、暂存区、分支的联系:
    github使用记录_第1张图片

你可能感兴趣的:(tools)