git基本指令
warning:
这篇文章距离上次修改已过457天,其中的内容可能已经有所变动。
Git是一个开源的分布式版本控制系统,可以有效、高效地处理从小型到大型项目的版本管理。以下是一些基本的Git指令:
- 初始化本地仓库:
git init- 克隆远程仓库:
git clone <repository_url>- 查看当前仓库状态:
git status- 添加文件到暂存区:
git add <file_name>
# 或者添加所有文件
git add .- 提交暂存区的变动到本地仓库:
git commit -m "commit message"- 将本地仓库的改动推送到远程仓库:
git push- 获取远程仓库的最新变动:
git pull- 查看提交历史:
git log- 创建分支:
git branch <branch_name>- 切换分支:
git checkout <branch_name>- 创建并切换到新分支:
git checkout -b <new_branch_name>- 合并分支:
git merge <branch_name>- 删除分支:
git branch -d <branch_name>- 撤销更改(工作区):
git checkout -- <file_name>- 撤销提交(撤销最后一次提交):
git reset --soft HEAD^- 删除文件:
git rm <file_name>- 查看远程仓库:
git remote -v- 添加远程仓库:
git remote add <remote_name> <repository_url>- 拉取特定分支的远程仓库:
git pull <remote_name> <branch_name>- 设置远程仓库:
git remote set-url <remote_name> <repository_url>这些是Git的基本指令,可以帮助开发者进行版本控制。
评论已关闭