git操作命令简单流程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39513166/article/details/82424381
  1. 创建分支并切换到分支:

    git checkout -b 分支名
    相当于:
    git checkout 分支名
    git branch 分支名 (这两句的组合)

  2. 查看当前所有分支(分支名前带*号的是当前所在分支):

    git branch

  3. 拉取代码:

    git pull <远程主机名> <远程分支名> (拉取远程代码到本地)

  4. 查看冲突

    git status -uno

  5. 添加要提交的代码:

    git add -A(提交全部文件) 或者 git add 要提交的文件路径(提交单个文件的时候)

  6. 提交代码:

    扫描二维码关注公众号,回复: 5483612 查看本文章

    git commit -m “注释说明”

  7. 切换分支:

    git checkout 分支名

  8. 合并分支代码到主分支上:

    git merge 分支名 (命令用于合并指定分支到当前分支)

  9. 查看提交日志:

    git log

  10. 上传代码:

    git push <远程主机名> <远程分支名>

  11. 查看状态:

    git status

  12. 删除分支:

    git branch -D 分支名

  13. 回退已经commit但是没有push的代码:

    git reset –hard commit_id
    例如:
    通过 git log 查看到提交日志:
    commit 1354755b95bf8a6d8d6f3cb3a16f6600c272e94
    Author: shiguangli [email protected]
    Date: Wed Sep 5 13:58:02 2018 +0800
    提交
    commit 1c44c592679df5dc5d891955895eb6f757df581
    Author: shiguangli [email protected]
    Date: Wed Sep 5 13:40:14 2018 +0800
    版豆红包修改
    现在要取消第一次提交那就输入:
    git reset –hard 1c44c592679df5dc5d891955895eb6f757df581
    即可回退到版豆红包修改这一版本了。

猜你喜欢

转载自blog.csdn.net/weixin_39513166/article/details/82424381
今日推荐