下面是工作学习中常用的一些git命令
1. 初始化 Git 仓库:
git init
2. 克隆远程仓库:
git clone <repository_url>
3. 查看当前文件状态:
git status
4. 添加文件到暂存区:
git add <file_name>
5. 添加所有文件到暂存区:
git add .
6. 提交更改:
git commit -m "Your commit message"
7. 查看提交历史:
git log
8. 查看远程仓库:
git remote -v
9. 添加远程仓库:
git remote add <remote_name> <repository_url>
10. 删除远程仓库:
git remote rm <remote_name>
11. 拉取远程仓库的更改:
git pull <remote_name> <branch_name>
12. 推送本地更改到远程仓库:
git push <remote_name> <branch_name>
13. 创建新分支:
git checkout -b <new_branch_name>
14. 切换分支:
git checkout <branch_name>
15. 合并分支:
git merge <source_branch_name>
16. 删除本地分支:
git branch -d <branch_name>
17. 删除远程分支:
git push <remote_name> --delete <branch_name>
18. 撤销工作区的更改:
git restore <file_name>
19. 撤销暂存区的更改:
git restore --staged <file_name>