GitHub常用命令及解释

 1、目录

cd ..              //返回上一级目录
ls 或者 dir        //查看当前目录下文件夹或者文件
cd /D              //进入某一个磁盘如D盘

2、查看工作区代码相对于暂存区的差别

git status

 3、提交文件

//将当前目录下修改的所有代码从工作区添加到暂存区 . 代表当前目录
//或者直接选择目标文件(test.txt)
git add . 
或者 
git add test.text

//将缓存区内容添加到本地仓库
git commit -m "注释"

//将本地版本库推送到远程服务器 master 为远程服务器分支
git push origin master

 4、创建SSH key

//查看ssh key 是否存在
cd ~/.ssh
ls

//创建ssh key
ssh-keygen -t rsa -C "你的注册邮箱"

5、建立版本库并提交

//常见目录
mkdir test

//进入该目录
cd test

//初始化
git init

//在github上创建仓库 并复制该地址

//关联本地仓库
git remote add origin 仓库地址

//遇到问题再使用下面命令,清理
git remote rm origin

//将代码由本地仓库上传到 github 远程仓库,依次执行下列语句
//获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)
git pull --rebase origin master

//把当前分支 master 推送到远程,执行此命令后有可能会让输入用户名、密码
git push -u origin master

6、删除文件

//删除本地
git rm -r --cached 文件名

//提交到暂存区
git commit -m "注释"

//提交到远程
git push -u origin master

7、手册

Main Porcelain Commands
   add                  Add file contents to the index
   am                   Apply a series of patches from a mailbox
   archive              Create an archive of files from a named tree
   bisect               Use binary search to find the commit that introduced a bug
   branch               List, create, or delete branches
   bundle               Move objects and refs by archive
   checkout             Switch branches or restore working tree files
   cherry-pick          Apply the changes introduced by some existing commits
   citool               Graphical alternative to git-commit
   clean                Remove untracked files from the working tree
   clone                Clone a repository into a new directory
   commit               Record changes to the repository
   describe             Give an object a human reada
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值