【git】git部分重要命令
1. git常用命令
git clone <url>: 克隆远程仓库到本地git clone --recursive <url>: 克隆远程仓库到本地,包括子模块vim .gitmodules: 查看子模块信息
git init: 初始化本地仓库git add <file>: 添加文件到暂存区git add .: 添加所有文件到暂存区
git commit -m <message>: 提交暂存区到本地仓库git status: 查看本地仓库状态git log: 查看提交日志git branch <branch_name>: 创建分支git checkout <branch_name>: 切换分支git checkout -b <branch_name>: 创建并切换分支git branch -d <branch_name>: 删除分支git branch -a: 查看所有分支git branch -vv: 查看所有分支与远程分支的连接关系git merge <branch_name>: 合并分支git remote: 查看当前连接的远程仓库git remote -v: 查看当前连接的远程仓库详细信息git remote add <remote_name> <url>: 添加远程仓库git remote remove <remote_name>: 删除远程仓库git remote set-url <remote_name> <url>: 修改远程仓库地址git remote rename <old_name> <new_name>: 修改远程仓库别名git fetch <remote_name>: 拉取远程仓库git fetch: 拉取当前连接的远程仓库- note:
git fetch拉取后不会对本地仓库进行改变,如需改变,需要使用git merge或git rebase
git pull <remote_name> <branch_name>: 拉取远程仓库到本地仓库git pull: 拉取当前连接的远程仓库到本地仓库- note:
git pull会改变本地仓库
git push <remote_name> <branch_name>: 推送本地仓库到远程仓库git push: 推送当前分支到远程仓库
git push <remote_name> <branch_name>:<remote_branch_name>: 推送本地仓库到远程仓库的指定分支git push <remote_name> --delete <branch_name>: 删除远程仓库的指定分支git reset --hard <commit_id>: 回退到指定commit版本git reset --hard HEAD^: 回退到上一个commit版本git reset --hard HEAD~n: 回退到前n个commit版本git reset --hard <commit_id>: 回退到指定commit版本`git tag <tag_name> <commit_id>: 给指定commit打标签git tag -a <tag_name> -m <message>: 给当前commit打标签git tag -d <tag_name>: 删除指定标签
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 tyhiwzm!
评论


