git 菜鸟级命令

本文提供了Git的基本操作指南,包括克隆远程仓库、状态查询、文件管理、提交更改、分支管理及合并等实用命令,适合初学者快速上手。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git clone [url]

获取一个 url 对应的远程 git repo, 并在本地创建一个  local copy


git status
查询 repo 的状态

git status -s
-s 表示short

git touch
新建一个文件

git touch Readme.md
新建一个名为 Readme.md 的文件

git vim
使用 vim 编辑器打开文件


git add
在提交之前,将新的改动添加到git 的暂存区,(staging area)。


git commit
将 add 到 staging area 中的改动提交。


gitk --all 
查看所有 branch 的历史纪录。 (上面 all 前面是两个减号 “  -  ”)


git push <remote> <branch>

将 <branch> push 到 <remote>。如果 <branch> 不存在则新建该 <branch>。


git remote
用于管理 git 为每一个 remote repo 的 url 建立的别名(alias)。


git remote -v
列出所有 remote aliases


git branch
列出 repo 中所有的 branch


git branch <branch>
创建名为 <branch> 的新的 branch


git checkout -b <branch>
新建一个名为 <branch> 并checkout(查看?)。如果要check out 已经存在的 branch,就把中间的 “ -b " 去掉。


git log
以默认形式显示所有commit history(提交记录?)。


git push <remote> <branch>
push your new branches and data to a remote repository.


git diff
show diff (differences) of unstaged changes.

比较工作目录中文件和 staging area 之间的差异。修改后还没有 staged 的变化。


git merge 
将一个 branch merge进当前的 branch


merge -about

git checkout -b

git branch -d

git echo "somefile.file" >> gitignore

git reset "somefile.file"

git reset HEAD~
                    ~~
                    ~~~
                    ~3

还是实践后加深理解吧。

a git cheat sheet might be helpful for a beginner.
click git cheat sheet to get it and enjoy it.






























评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值