zoukankan      html  css  js  c++  java
  • git常用指令(sourceTree挺香的)

    提交代码一般流程(不推荐使用. 泛指需要提交的文件)

    1. git add .
    2. git commit -m 'some message'
    3. git pull origin master
    4. git push origin master

    设置用户名和密码

    git config --global user.name "Your name"
    git config --global user.email "email@example.com"

    初始化本地git仓库

    git init (on the directory wanna set as repository)
    ps : commond ll -a to make sure the .git file created

    查看提交日志

    git log;
    git log --pretty=oneline;

    回滚

    HEAD 是版本标记,用于版本回滚,可使用git log 查看
    git reset --hard commit_id
    忘记回滚版本可使用git reflog查看历史命令

    撤销修改:

    add 之前:git checkout -- <file_path>
    add 之后:git reset HEAD <file_path> 然后 git checkout -- <file_path>
    git push origin 分支名
    本地库代码推送到远程库, 多人协作时在push之前要先pull

    第一次推送代码:git push -u origin master

    git branch

    列出所有分支(本地库)

    git fetch

    同步本地库和远程库的分支

    git branch <分支名>

    创建分支

    git checkout <分支名>

    切换分支

    git checkout -b <分支名>

    创建,切换分支

    git merge <分支名>

    合并分支代码到当前分支

    git branch -d <分支名>

    删除分支

    git log --graph
    show git branch praph
    来自基友 爆炸峰

  • 相关阅读:
    UVA756
    SP30906
    SP32900
    CF940F
    洛谷P5030
    洛谷P5142
    洛谷P2569
    网络流 24 题做题记录
    矩阵
    二分图
  • 原文地址:https://www.cnblogs.com/caoxueyang/p/13070298.html
Copyright © 2011-2022 走看看