zoukankan      html  css  js  c++  java
  • 简单记录常用git 命令

    声明:仅作笔记用

    拉取远程代码

    1.git pull

    2.如果需要,输入账户名密码

    将本地代码推送到远程

    1.git push

    2.如果需要,输入账户名密码

    同步远程分支

    1.git fetch

    2.git checkout -b local-branchname origin/remote_branchname

    运行 git fetch,可以将远程分支信息获取到本地,再运行 git checkout -b local-branchname origin/remote_branchname  就可以将远程分支映射到本地命名为local-branchname  的一分支

    改变远程路径 https改成ssh(这样就不用每次拉取或者推送代码的时候输入用户名密码了)

    1.

    git remote -v
    origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
    origin  git@github.com:USERNAME/REPOSITORY.git (push)

    2.

    git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git

    3.

    git remote -v
    # Verify new remote URL
    origin  https://github.com/USERNAME/OTHERREPOSITORY.git (fetch)
    origin  https://github.com/USERNAME/OTHERREPOSITORY.git (push)

    附:要想懒得输入用户名密码还得配置SSH,要先生成一个密钥

    $ ssh-keygen -t rsa -C "*****@.qq.com"

    然后把你生成的内容复制到远程的这个地方就可以了。

    查看远程分支

    $ git branch -a

    查看本地分支

    $ git branch

    创建分支

    $ git branch test

    切换分支到test

    $ git checkout test

    删除本地分支   git branch -d xxxxx

    查看本地和远程分支  -a。前面带*号的代表你当前工作目录所处的分支

    强制撤销修改

    先找到你要回到的哪一次提交

    git log

    git reset --hard ****

    git status 看看有啥要处理的

    删除远程目录

    git rm -r --cached dirname
    git commit -m 'say something'
    git push origin master

    持续添加中~~~

  • 相关阅读:
    Codeforces
    Codeforces
    SCUT
    模板
    SCUT
    SCUT
    模板
    SCUT
    UVA 437 "The Tower of Babylon" (DAG上的动态规划)
    UVA 1025 "A Spy in the Metro " (DAG上的动态规划?? or 背包问题??)
  • 原文地址:https://www.cnblogs.com/AlexBlogs/p/6443914.html
Copyright © 2011-2022 走看看