记录一些语法,希望自己看到的时候可以起到复习的作用
echo 写入
echo "This is a text" >> Filename
branch 分支展示
$ git branch
* dev
main
星号代表当前分支
cat 打开文件
$ git cat Filename
#
There is data
#
status 显示当前状态
$ git status
On branch dev
nothing to commit, working tree clean
add 把文件加入缓存区
$ git add Filename
commit 把文件提交保存
//基础使用
$ git commit -m "log"
commit c3f40a2dbab0a60e4426050f03d24bba7e1a61c6
Author: zhywyt <[email protected]>
Date: Thu Feb 16 17:52:16 2023 +0800
Your Log
cd 切换盘符
cd Filename
$ cd learngit
reflog 历史更新记录
$ git reflog
90d67c7 (HEAD -> main, origin/main) HEAD@{0}: checkout: moving from dev to main
847265a (dev) HEAD@{1}: checkout: moving from main to dev
checkout 用于分支
创建分支分支
$ git checkout -b BranchName
merge 合并分支
$ git merge BranchName
Updating d46f35e..b17d20e
Fast-forward
readme.txt | 1 +
1 file changed, 1 insertion(+)
合并指定分支到当前分支,其中的##Fast-forward##是指快进模式,也就是直接把main指针指向了dev
branch -d 删除分支
$ git branch -d dev
Deleted branch dev (was ...)