Git Product home page Git Product logo

getgit's Introduction

init git

mkdir learngit
cd learngit
pwd

git init 

touch readme.md
git add readme.md
git commit -m "add a markdown file"

change file and diff

git status
git diff readme.md

git add readme.md
git commit -m "change file and diff"
git status

git log and reset

git log # 显示版本
git log --pretty=oneline

git reset --hard HEAD^  ##回退一个版本
git log 

git reset --hard 6983  # 根据hash前几位指定版本

stage, add and commit

touch license

## change license and readem.md

git status ## 显示工作区 stage 变化
git add readme.md
git status
git add license
git status
git commit

git add readme.md
git add readme.md
git commit ## 多次修改放到暂存区

checkout -- file

回退未add的修改

## change readme.md
123

git checkout -- readme.md

将未commit的add到暂存区的回退 unstage

123
git add readme.md
git reset HEAD readme.md 

两次add 后怎么推到第一次add的?

remove and checkout back

rm license 
git status

git rm license 
git satus
git commit -m "rm license" ## rm file in folder and in git

rm license 
git checkout -- license ## recover

remote repo

ssh-keygen -t rsa -C "[email protected]" 

id_rsa id_rsa.pub公钥

git remote add origin [email protected]:AdamZh0u/GetGit.git ## origin

git push -u origin master ## --upstream 远程origin 

branch create and quick merge

## create branch and switch to
git checkout -b dev 

# or 
git switch -c dev
# or 
git branch dev  ## == git branch -c dev
git checkout dev

touch license
## do changes in license 
git add license 
git commit -m "add license to dev"

## 
git checkout master
git merge # quick merge mode

git branch -d dev

git conflict

git switch -c dev
## change
git add / git commit -m "switch -c dev"/ git push origin dev

git switch master
## change
git add / git commit -m "change in master branch" / git push

git merge dev ## conflicts
## 手动修改
git add .
git commit -m "fix conflict" / git push 

git log --graph --pretty=oneline --abbrev-commit

git branch -d dev

fork workflow

fork repo1
git clone frepo1
git remote -v # show frepo1
git remote add upstream repo1
git remote -v # show frepo1 repo1

git checkout -b branch master
## changing on branch

git checkout master
git pull upstream master
## pull new changes to local master

git checkout -b branch_new master
git merge branch
git branch -m branch_new branch## rename
git push origin branch

pull request merge branch to master

resources: https://github.com/dtbootcamp/getting-started-with-git-and-github

getgit's People

Contributors

adamzh0u avatar adamzhou3 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.