每个开发人员都必须知道的 Git 命令
大家好,早上好 ☕
我知道我最近没怎么写东西,但现在我又开始疯狂写作了 🎉
今天我们将学习一些很棒的 git 命令,每个开发人员都必须知道。当我强调“必须”这个词时,请仔细阅读。掌握这些命令绝对能让你的工作更轻松。😉
那就开始吧。
- 初始化本地 git 仓库
git init
- 将特定文件添加到存储库
git add git_commands.md
- 将所有未提交的文件添加到存储库
git add .
- 设置存储库
git config --global user.name 'mursalfk'
git config --global user.email 'mursalfurqan@gmail.com'
- 向您的提交添加消息
git commit -m "You can add a message to your commit like this"
- 查看提交历史记录
git log
- 添加远程名称/URL
git remote add origin 'https://github.com/mursalfk/mursalfk.git'
- 将更改推送到远程存储库
git push origin master
- 克隆任意存储库
git clone 'https://github.com/mursalfk/mursalfk.git'
- 更新当前工作目录
git pull origin master
- 检查提交之间的差异
git diff HEAD~1 HEAD
- 从任何存储库下载文件
git fetch origin master
- 创建新分支
git branch branchName
- 在文件夹内创建新分支
git branch branchFolder/branchName
- 切换到另一个分支
git checkout branchName
- 切换到另一个文件夹中的另一个分支
git checkout branchFolder/branchName
- 同时创建并签出到新分支
git checkout -b branchName
- 同时创建并签出另一个文件夹中的新分支
git checkout branchFolder/branchName
- 合并到新分支
git merge master