Git Product home page Git Product logo

study-history's Introduction

Study-History

git 相关操作

连接到远程仓库

1.初始化本地仓库 git init 2.连接远程仓库 git remote add origin 远程仓库地址

查看分支

  1. 查看远程分支:git branch -r
  2. 查看本地分支:git branch

创建和切换分支

  1. 创建新分支:git branch 新分支名称
  2. 切换分支:git checkout 分支名称
  3. 创建分支的同时,切换到该分支:git checkout -b 新分支名称

从远程仓库pull(拉取)代码到本地分支

  1. 指定远程分支和本地分支:git pull origin 远程分支名:本地分支名
  2. 不写本地分支名,默认与远程分支同名;git pull origin 远程分支名

将新分支推送到远程仓库

  1. git push origin 分支名称
  2. 假设本地创建了名为dev的分支,远程仓库没有该分支,则:git push --set-upstream origin dev

删除分支

  1. 删除本地分支(不能删除当前所在分支,必须先切换):git branch -d 分支名
  2. 可以强制删除:git branch -D 分支名
  3. 删除远程分支:git push origin :分支名

合并分支

  1. 假设我们在分支dev上,完成自己负责的功能,并执行了以下命令   git add .   git commit -m "某某功能完成,提交到[分支名]分支"   git push -u origin 分支名
  2. 首先切换到master分支   git checkout master
  3. 如果是多人开发,需要把远程master分支上代码pull下来   git pull origin master
  4. 把dev分支的代码合并到master上,如果出现冲突,可以执行第二个命令取消merge   git merge 分支名   git merge --abort:
  5. 查看状态   git status
  6. push推送到远程仓库   git push origin master

study-history's People

Contributors

1957278559 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.