常用git指令
-
初始化Git仓库:
git init
-
添加文件到暂存区:
git add <file>
-
提交更改到本地仓库:
git commit -m "commit message"
-
查看本地仓库的提交历史:
git log
-
创建分支:
git branch <branch_name>
-
切换分支:
git checkout <branch_name>
-
查看所有分支:
git branch
-
合并分支:
git merge <branch_name>
-
拉取远程仓库的更改:
git pull
-
推送本地更改到远程仓库:
git push
-
删除本地文件:
git rm <file>
-
恢复删除的文件:
git rm --cached <file>
-
强制删除本地文件:
git force-remove <file>
-
显示所有已合并的远程分支:
git fetch --all
-
显示本地仓库与远程仓库的差异:
git diff
-
提交更改并关联到指定的远程分支:
git push -u origin <branch_name>