加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Git Commands

发布时间:2020-12-14 16:36:26 所属栏目:百科 来源:网络整理
导读:Git Version $ git --version Git Config 1. set user name,email $ git config --global user.name MudOnTire $ git config --global user.email 895157882@qq.com 2. get config $ git config user.name $ git config user.email Repository 1. git init $

Git Version

$ git --version

Git Config

1. set user name,email

$ git config --global user.name MudOnTire

$ git config --global user.email 895157882@qq.com

2. get config

$ git config user.name

$ git config user.email

Repository

1. git init

$ git init

2. git status

$ git status

3. stage file

single file

$ git add index.html 

all changed files

$ git add .

4. unstage file

$ git rm --cache index.html

5. commit

make commit

$ git commit -m "add index and style files"

show history

$ git log

show condensed commit

$ git log --oneline

Undo Commits

1. checkout commit

$ git checkout 0e2a5f3

2. reattach to branch

$ git checkout master

3. revert commit (undo one particular commit)

$ git revert eb95c64

4. reset commits

soft (retain changes)

$ git reset eb95c64

hard (erase all changes)

$ git reset eb95c64 --hard

create branch

1. show branches

$ git branch -a

2. create a branch

$ git branch feature-1

3. switch to a branch

$ git checkout feature-1

4. delete a branch

$ git branch -D feature-1

5. create and then switch to a branch

$ git checkout -b feature-1

merge branch

1. merge target branch to current branch

$ git merge [name_of_target_branch]

2. push local branch to remote

$ git push origin [name_of_your_new_branch]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读