Coder Social home page Coder Social logo

git_use's Introduction

commonly used git command

git connfig --global user.name '{name}'
git config --global user.email '{email}'
ssh-keygen -t rsa -C '{email}'
cat ~/.ssh/id_rsa.pub

生成git ssh key 并查看, 可以添加到远程的ssh key 中。

git remote add origin {url}  

设置git远程仓库地址

git remote set-url origin {url} 

修改远程仓库地址

git push -u origin master 

首次把本地仓库同步到远程master

git remote -v 

查看远程仓库地址

git branch -r

查看远程分支

git branch

查看本地分支

git push origin :{branch-name}

删除远程分支

git branch -D {branchname}

删除本地分支

git checkout -b {branchname} 

新建并切换到 分支 branchname

git fetch
git checkout -b {localBranchName} origin/{originBranchName}

拉取远程分支到本地分支

git push origin develop:master -f 

把本志的develop分支强制推送到远程master

git push origin master -f 

强制推送到远程master分支

git checkout master && git reset --hard develop 

切换本地分支到master, 并且把master分支内容重置为develop分支内容

git submodule add [--force] {url} {dirname} 

把另一个git仓库作为子模块加到当前项目的 dirname目录

git submodule update --init --recursive

初始化git子模块项目

git rm {dirname}  && rm .gitmodules

删除git子模块

git log --pretty=format:"%h" -n {n}

提取最后n次提交的短commitId

git rev-parse --short HEAD

提取最后一次提交的短commitId

git rev-parse HEAD

提取最后一次提交的长commitId

{% include_relative centos.md %}

git_use's People

Contributors

yhc-yhc avatar

Watchers

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