Giter Club home page Giter Club logo

git's Introduction

git

git 是一个很强大的分布式版本管理工具,它不但适用于管理大型开源软件的源代码(如:linux kernel),管理私人的文档和源代码也有很多优势

安装

在官方下载对应系统版本并默认安装。下载

常用命令

初始化命令(windows)

  • git config --global user.name 'userName' 设置git账户,userName为你的git账号
  • git config --global user.email 'email'

ssh for git(windows)

  • cd ~/.ssh 如果提示没有该路径则手动新建一个 mkdir .ssh
  • ssh-keygen -t rsa -C 'email' 一直回车直到生成 ssh,在目录中会生成两个文件:id_rsa和id_rsa.pub
  • vim id_rsa.pub,在打开的文件中复制 ssh

ssh for git (mac or linux)

传送门

远程仓库基本命令

  • git clone [url] 下载远程仓库
  • git remote -v 查看远程仓库
  • git remote add [name] [url] 添加远程仓库 如 git remote add origin https://github.com/dk-lan/git.git
  • git remote rm [name] 删除远程仓库
  • git remote set-url --push [name] [newUrl] 修改远程仓库
  • git pull [remoteName] [localBranchName] 拉取远程仓库
  • git push [remoteName] [localBranchName] 推送远程仓库

本地仓库基本命令

  • git init 初始化仓库
  • git status 查看本地仓库状态
  • touch .gitignore 仓库忽略文件 写入不需要的文件夹名或文件,每个元素占一行即可,如 /node_modules/
  • git add [filename][.] 添加
  • git commit -m "message" 提交到本地仓库

分支管理

  • git branch 查看本地分支
  • git branch -r 查看远程分支
  • git branch [name] 创建本地分支 注意新分支创建后不会自动切换为当前分支
  • git checkout [name] 切换分支
  • git checkout -b [name] 创建新分支并立即切换到新分支
  • git branch -d [name] 删除分支 -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项
  • git merge [name] 合并分支 将名称为[name]的分支与当前分支合并
  • git push origin [name] 创建远程分支(本地分支push到远程)
  • git push origin :heads/[name] 或 $ gitpush origin :[name] 删除远程分支

如果不喜欢用命令行的可以用可视化工具

传送门

git's People

Contributors

success666 avatar

Watchers

James Cloos 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.