
初始化一个新的 Git 仓库:
git init
添加文件到暂存区:
git add <file name>
提交更改到本地仓库:
git commit -m "Commit message"
将本地仓库的更改推送到远程仓库:
git push origin <branch name>
从远程仓库获取最新的更新:
git pull origin <branch name>
切换分支:
git checkout <branch name>
创建新的分支:
git branch <branch name>
删除分支:
git branch -d <branch name>
查看分支列表:
git branch
合并分支:
git merge <branch name>
查看提交历史:
git log
查看当前仓库状态:
git status
添加远程仓库:
git remote add origin <remote repository URL>
从远程仓库克隆到本地:
git clone <remote repository URL>
查看远程仓库列表:
git remote -v
撤销暂存的文件:
git reset HEAD <file name>
恢复文件到最近一次提交的状态:
git checkout -- <file name>
创建标签:
git tag <tag name>
列出标签:
git tag
重置到指定的提交:
git reset <commit hash>
这些示例覆盖了 Git 的一些常用功能和选项,可以帮助你开始使用 Git。请注意,Git 的功能非常丰富,还有很多其他命令和选项可供探索和学习。建议你参考 Git 的官方文档以获取更详细的信息和更多的功能示例。