美文网首页
Git 常用命令总结

Git 常用命令总结

作者: Emonzan | 来源:发表于2022-05-17 14:45 被阅读0次

现在我们无论是公司或者是个人项目,都常常用到Git,作为一个开源的版本控制系统,在我用过的所有版本控制系统中,它是最好用的了(截止到写这篇文章的2022年)。这里记下一些常用命令。具体的命令大全可以参考Git.

仓库(Repository)

  1. git init, 创建一个新的本地仓库
  2. git clone,check out a repository

提交代码

  1. status
    git status, 列出有改动,目前需要提交的文件。
  2. Add files
    git add <filename>
    git add *, 添加一个或多个文件到stating
  3. Commit
    git commit -m "Commit message", commit changes to head(but not yet to remote repository).
    git commit -a, commit any files you've added with git add, and also commit any files you've add since then.
  4. Push
    git push origin master, send changes to the master branch of your remote repository.

撤销本地的改动

  1. git checkout -- <filename>, replace the changes in your working tree with the last content in the head. Changes already added to the index, as well as new files, will be keep.
  2. git fetch origin
    git reset --hard origin/master ,放弃本地所有的改动和提交,fetch the latest history from the server and point your local masrer branch at it.

分支(branches)

  1. git checkout -b <branchname>, 创建一个新的分支,并且切换到它。
  2. git branch -d <branchname>, 删除分支。
  3. git push origin <branchname>,Push the branch to your remote repository, so others can use it.
  4. git push --all origin, push all branches to your remote repository.
  5. git push origin :<branchname> 删除你远程仓库的分支。

update from remote repository

  1. git pull Fetch and merge changes on the remote server to your working diectory.2.
  2. git merge <brandbane>, merge a different branch to your active branch.
  3. git diff, view all the conflicts.
    git digg --base <filename>, view the conflicts against the base file.
    git diff <sourcevbranch> <targetbranch>, preview changes before merge
  4. git add <filename>,解决冲突之后,手动添加更新过的文件

相关文章

  • git 命令

    Git常用命令总结Git常用命令总结 git init 在本地新建一个repo,进入一个项目目录,执行git ...

  • Git 常用指令

    Git常用命令总结 Git常用命令总结 git init 在本地新建一个repo,进入一个项目目录,执行git i...

  • git相关教程汇总

    1. git常用命令 git常用命令总结git常用命令讲解 2. git教程相关网站 廖雪峰的git教程猴子都能懂...

  • Git与Github的使用总结 - day 03

    git常用命令总结 git配置(config): git仓库(repository): git分支(branch)...

  • Git 常用命令

    Git更多详细介绍 查看git-book git教程 - 廖雪峰 Git 常用命令 总结 $ git init 通...

  • Git常用命令

    Git 常用命令总结 git的一些基础命令 Git常用命令 一般配置 登录git 创建一个文件夹 初始化git仓库...

  • git常用命令

    对git常用命令做个总结,以便以后使用:

  • GIT 常用命令总结

    GIT 常用命令总结 GIT 初始化命令 命令描述git init初始化本地 git 仓库git config -...

  • Git常用命令总结

    Git常用命令总结 1,初始化:git init 创建git仓库 2,配置用户:git config --glo...

  • Git常用命令总结

    我学习效率比较低,关于git差不多学习了两周,总结的常用命令如下: git add .&&git commit -...

网友评论

      本文标题:Git 常用命令总结

      本文链接:https://www.haomeiwen.com/subject/lulnurtx.html