-
指定名字和邮箱
-
设置全局名称和邮箱
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
-
设置当前仓库的名称和邮箱
git config user.name "Your Name" git config user.email "your.email@example.com"
-
-
初始化仓库
git init
-
添加文件至暂存区
-
添加单个文件
git add [file name]
-
添加全部修改过的文件
git add .
-
-
提交更改文件
要先将修改的文件添加至暂存区才能提交
git commit -m "[Prompt information]"
-
查看文件状态
git status
显示工作目录和暂存区的状态,包括未跟踪的文件、已修改但未暂存的文件以及已暂存等待提交的文件。
-
查看差异
git diff
比较工作目录和暂存区之间的差异,显示尚未暂存的改动。
-
查看提交历史
git log
-
管理分支
-
创建分支
git branch [Branch name]
-
切换分支
git checkout [Branch name]
-
合并分支
git merge [Branch name]
-
删除分支
-
删除本地分支
-
安全删除
git branch -d <branch-name>
-
强制删除
git branch -D <branch-name>
注:两者的区别在于安全删除是删除合并后的分支的,强制删除是删除未合并的分支的
-
-
删除远程分支
git push [repository-name] --delete <branch-name>
-
-
-
拉取和推送
-
拉取远程仓库
git pull [repository-name] [主分支名]
git clone [Warehouse address]
git pull
和git clone
的区别:git clone
是用来初始化一个新的本地仓库副本,而git pull
则是在已有本地仓库的基础上同步并合并远程仓库的更新。 -
推送
git push
-
Git学习笔记-常用命令
最新推荐文章于 2024-05-30 14:51:18 发布