GIT

working directory: 工作空间,对应本地文件系统上的目录

staging area: 暂存区,临时存放准备提交的修改的区域

local repositroy: 本地仓库,位于.git目录下

 

git version 2

 

git add

添加指定文件到暂存区
git add [file1] [file2] ...

添加指定目录到暂存区,包括子目录

git add [dir]

添加当前目录的所有文件到暂存区

git add .

添加当前目录的所有文件到暂存区(但不包括新文件)

git add -u

 

git restore (2.23+)

回退暂存区指定文件
git restore --staged [file1] [file2] ...
 
回退暂存区中当前目录的所有文件
git restore --staged .

回退工作区指定文件的修改到上一次提交的状态(即放弃本地所做的修改,此操作无法回退)

git restore [file1] [file2] ...

回退工作区当前目录的所有文件的修改到上一次提交的状态(即放弃本地的修改,此操作无法回退)

git restore .

 

git commit

提交暂存区到本地仓库
git commit -m "descriptive commit message"

提交暂存区的指定文件到本地仓库

git commit [file1] [file2] ... -m "descriptive commit message"

提交工作区自上次 commit 之后的变化,直接到仓库区(但不包括新文件)。

git commit -am "descriptive commit message"

合并到上一次提交。如果代码没有任何新变化,则可用来改写上一次 commit 的提交信息

git commit --amend -m "descriptive commit message"

 

git push

上传本地指定分支到远程仓库

 git push [remote] [branch]
 
强行推送当前分支到远程仓库,会照成远程分支的修改丢失,慎用。
  git push [remote] --force
 
 
git pull
 
取回远程仓库的变化,并与本地分支合并
  git pull [remote] [branch]
使用git rebase 进行代码合并而不是 get merge
  git pull --rebase [remote]
 
 
 

 

 

 

 

posted @ 2022-03-08 20:00  nozbwang  阅读(23)  评论(0编辑  收藏  举报