git安装及命令的使用+github

git安装及命令的使用

目录

git安装及命令的使用

一、安装

二、命令

(1)基本命令

三、如何把代码上传到github

(1)生成公钥

         (2)在github上配置公钥

(3)依次按照命令提交

四、问题及注意


一、安装

下载:Git-2.6.1-64-bit.exe,依次点击下一步就好

二、命令

(1)基本命令

  • 把本地目录变成git可以管理的目录:git init 
  • 拉取远程的Repo到本地:git clone xxxxxx
  • 从repository拉去内容:git pull
  • 从分支上拉去内容:git pull origin master
  • 跟踪某一文件:git add readme.txt
  • 跟踪全部文件:git add .
  • 提交到本地库:git commit -m "first commit"
  • 连接远处库:git remote add origin [email protected]:XXX/XXXXX.git
  • 提交到远程库master分支:git push -u origin master
  • 在本地仓库删除文件 :git rm 我的文件
  • 在本地仓库删除文件夹:git rm -r 我的文件夹。此处-r表示递归所有子目录,如果你要删除的,是空的文件夹,此处可以不用带上-r。
  • 返回上一级目录:cd .. (cd 与 .. 之间有一空格)。
  • 进入某一目录:cd git (进入 git 目录)。
  • 显示当前路径:pwd

三、如何把代码上传到github

(1)生成公钥

         https://www.cnblogs.com/amaoxiaozhu/p/3319233.html

(2)在github上配置公钥

(3)依次按照命令提交

         详细:——https://www.cnblogs.com/myFourLeaf/p/5229309.html
                   ——https://www.cnblogs.com/cxk1995/p/5800196.html

                 ——https://blog.csdn.net/Bright2017/article/details/70833336

四、问题及注意

(1)Not a git repository (or any of the parent directories): .git

——https://blog.csdn.net/ydm19891101/article/details/72416917

(2)github删除repository

——http://www.cnblogs.com/lizhenghn/p/3679293.html

(3)如果拒绝提交,需要先git pull在提价远程库

猜你喜欢

转载自blog.csdn.net/qq_42683700/article/details/81982975