git命令行学习

git知识学习网址

  •  克隆仓库到本地:git clone 

  •  查看状态:git status   

  • 给文件添加跟踪:git add fileName / .          

  • 忽略文件:cat .gitignore

  • 查看尚未暂存的文件更新了哪些部分:git diff  

  • 查看已经暂存起来的变化:git diff --cached      

  • 提交  ,每次准备提交前,先用 git status 看下,是不是都已暂存起来了:git commit -m ''      

  • 连带从工作目录中删除指定的文件:git rm           

  • 移动文件,可以用来重命名:git mv file_from file_to  

  • 查看提交历史, -p:显示每次提交的内容差异 , -2: 来仅显示最近两次提交:git log  /  git log -p -2             

    扫描二维码关注公众号,回复: 4685101 查看本文章
  • 每次提交的简略的统计信息:git log --stat                 

  • 取消暂存的文件:git reset HEAD <file>        

  • 查看关联的远程仓库:git remote -v  

  • 关联远程仓库 git remote add 仓库命名 http://…

  • 推送到远程仓库:git push origin master

  • 拉取远程仓库代码:git pull origin master

  • 查看远程仓库:git remote show origin

  • 重命名远程仓库:git remote rename oldName newName

  • 移除远程仓库:git remote rm name

  • 查看标签:git tag / git tag v1.0

  • 创建附注标签:git tag -a v1.0 -m ‘my version v1.0'

  • 查看标签信息与对应的提交信息:git show / git show v1.0

  • 共享标签(创建标签需要手动push到共享服务器):git push origin v1.0 / —tags

  • 创建分支 git branch name 

  • 查看分支 git branch

名词:

  1. Untracked files  Git 在之前的快照(提交)中没有这些文件

  2. 在 Changes to be committed 这行下面的就是已暂存状态

  3. 在 Changes not staged for commit 这行下面说明已跟踪文件的内容发生了变化,但还没有放到暂存区。 要暂存这次更新,需要运行 git add 命令

猜你喜欢

转载自blog.csdn.net/ljw2017/article/details/85136432
今日推荐