Git 是一个流行的分布式版本控制系统,以下是一些常用的 Git 操作命令:
- 初始化仓库:
git init
- 克隆仓库:
git clone <repository-url>
- 添加文件到暂存区:
git add <file>
- 提交文件到版本库:
git commit -m "commit message"
- 查看当前文件状态:
git status
- 查看提交历史:
git log
- 查看远程仓库:
git remote -v
- 拉取远程仓库的更新:
git pull
- 推送本地提交到远程仓库:
git push
- 创建分支:
git branch <branch-name>
- 切换分支:
git checkout <branch-name>
- 合并分支:
git merge <branch-name>
- 撤销文件的修改:
git checkout -- <file>
- 回滚到某个特定的提交:
git reset --hard <commit-hash>
- 创建一个新的提交来回滚之前的提交:
git revert <commit-hash>
- 丢弃本地的更改:
git checkout -- <file>
这些是一些最常用的 Git 操作命令,希望对你有帮助!