git常用命令


  1. 切换拉取分支:

    git branch (查看本地分支):查看

    git branch -a (查看本地+远程所有分支):查看

    git checkout -b dev(自己取的名) origin/develop(要拉取的远程分支全名) :新建并拉取

    git checkout master:切换到主干

  2. 代码丢失回退版本:

    git reflog(查看历史commit记录)

    git reset --hard 51d2f59(上述某版本)

  3. 本地代码合并到主干:

    git checkout master:切换到主干

    git pull origin master:先拉一下

    git merge dev:合并分支到主干

    git status:查看下状态

    git push origin master:把代码推到远程主分支

  4. 在全局存储账号密码:

    C:\users\Administrator目录创建.git-credentials文件,touch .git-credentials,输入https://username:password@github.comgit config --global credential.helper store永久存储就可以了

    https://blog.csdn.net/qq_28602957/article/details/52154384