zoukankan      html  css  js  c++  java
  • git常用的命令

    git是一个版本控制软件,能在linux、windows和其它的操作系统平台上使用,功能非常强大,而且使用非常简单,下面是一些自己常用的命令:

    一、设置用户信息
    1.git config --global user.name "name"
    2.git config --global user.email "email@163.com"

    二、git增加文件
    1.git add . #把文件暂时存放到stage里,然后用commit命令提交
    2.git add filename #添加文件
    3.git add folder #添加文件夹
    4.git add -u #只加修改过的文件,新增加的文件不加入
    5.git add -i #进入交互模式

    三、git删除文件
    1.git rm filename

    四、git重命名文件或者文件夹
    1. git mv filename new-filename
    2. git mv folder new-folder

    五、git查看目前的状态
    1. git status

    六、git提交
    1.git commit -m 'commit msg'
    2.git commit -a -m 'commit msg' #新增加的文件或者文件夹要先用git add命令

    七、git标签
    1.git tag #查看所有的标签文件
    2.git tag name #软标签
    3.git tag -a name -m 'tag msg' #硬标签
    4.git tag -d #删除标签

    八、git分支操作
    1.git branch #查看所有的分支以及当前的分支是哪个
    2.git branch newbranch #建立新的分支
    3.git checkout newbranch #切换到新的分支
    4.git branch -d newbranch #删除分支
    5.git branch -D newbranch #强制删除分支,用于分支失败的情况

    九、git的show操作
    1.git show 310a #commit 310ab3d2bf8e7b9649b00a14bd642dfe77bc26ac的内容
    2.git show v1.0 #查看标签v1.0的内容
    3.git show v1.0:index.php #查看标签v1.0的index.php的内容
    4.git show HEAD #此版本修改的资料
    5.git show HEAD^ #前一版本修改的资料
    6.git show HEAD^^ #前前一版本修改的资料

    十、git的还原操作
    1.git reset --hard HEAD #还原到最前面
    2.git reset --hard tag标签 #还原到tag标签的内容(硬标签)
    3.git reset --soft tag标签 #还原到tag标签的内容(软标签)

    十一、git的log操作
    1.git log #列出所有的log
    2.git log -p #列出所有的log和修改过的内容

    十二、git的diff操作
    1.git diff #比较工作区域与staging区域
    2.git diff --cached #比较staging区域与Repository
    3.git diff tag1 tag2 #比较tag1与tag2

    4.git diff master branch #查看分支之间的差异

    转自 : http://www.52gvim.com/article/git%E5%B8%B8%E7%94%A8%E7%9A%84%E5%91%BD%E4%BB%A4/

  • 相关阅读:
    rmq +二分暴力 hdu 5726
    8.25 ccpc 比赛总结
    莫比乌斯反演题目总结
    HDU 4848 Wow! Such Conquering! (搜索+floyd)
    Codeforces 982 C Cut 'em all!(DFS)
    Codefoces 986C AND Graph(DFS)
    CodeForces 986A Fair(BFS)
    ACM经验贴
    Kattis A+B Problem(FFT)
    CF E. Porcelain (双向dp)
  • 原文地址:https://www.cnblogs.com/robbychan/p/3786596.html
Copyright © 2011-2022 走看看