git 常用命令并分别举实例
-
git init:在当前目录下初始化一个新的Git仓库。 例:在项目文件夹中运行git init命令,初始化一个新的Git仓库。
-
git clone:克隆一个远程Git仓库到本地。 例:git clone https://github.com/example/repo.git
-
git add:将文件添加到暂存区。 例:git add file.txt
-
git commit:将暂存区中的文件提交到本地仓库。 例:git commit -m "Add file.txt"
-
git push:将本地仓库中的提交推送到远程仓库。 例:git push origin master
-
git pull:从远程仓库拉取最新的代码到本地仓库。 例:git pull origin master
-
git status:查看当前仓库的状态。 例:git status
-
git log:查看提交历史。 例:git log
-
git branch:列出所有分支或创建新分支。 例:git branch new_branch
-
git checkout:切换到指定分支或恢复文件。 例:git checkout new_branch
-
git merge:将指定分支的修改合并到当前分支。 例:git merge new_branch
-
git remote:管理远程仓库。 例:git remote add origin https://github.com/example/repo.git
-
git stash:将当前工作区的修改储藏起来。 例:git stash
-
git reset:撤销提交或将文件从暂存区移除。 例:git reset HEAD file.txt
-
git diff:查看文件的修改内容。 例:git diff file.tx
原文地址: https://www.cveoy.top/t/topic/iy2S 著作权归作者所有。请勿转载和采集!