企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## Git常用操作 ### 常用操作 | 命令 | 说明 | | --- | --- | | git init | 在现有目录中初始化仓库 | | git clone git@github.com:wenshunbiao/learngit.git | 克隆现有的仓库 | | git add \<file> | 跟踪新文件或把文件修改添加到暂存区(stage) | | git commit -m "更新说明" | 提交更新到本地版本库 | | git push origin master | 推送到远程master分支(可加`-u`参数关联) | | git pull origin master | 从远程仓库master分支拉取内容 | | git status | 查看已暂存和未暂存的修改 | | git diff \<file> | 查看已暂存和未暂存的修改 | | git commit --amend | 修改最后一次提交的commit | | git rm -r --cached logs | 移除 `logs` 目录的版本控制,`--cached` 只去除版本控制而不删除本地文件 | | git config --global user.name "yourname" | 设置用户名 | | git config --global user.email "youremail" | 设置邮箱 | | git config --list | 查看配置信息 | ### 分支管理 | 命令 | 说明 | | --- | --- | | git merge --no-ff develop | 合并develop分支到当前分支 --no-ff不使用fast-forward方式合并,保留分支的commit历史 | | git merge --no-ff origin/develop | 合并远程develop分支到当前分支 | | git branch | 查看分支(`-a`参数可查看远程分支) | | git checkout -b develop | 创建并切换到develop | | git checkout develop | 切换到develop分支 | | git branch -d develop | 删除本地develop分支 | | git push origin --delete develop | 删除远程develop分支 | ### 标签管理 | 命令 | 说明 | | --- | --- | | git tag | 列出标签 | | git tag -l "v1.8.5*" | 按照特定的模式查找标签 | | git tag v1.4 | 创建一个轻量标签 | | git tag -a v1.4 -m "my version 1.4" | 创建一个附注标签 | | git show v1.4 | 查看标签信息和与之对应的提交信息 | | git tag -a v1.2 9fceb02 | 给过去的提交补打标签 | | git push origin v1.4 | 将v1.4标签推送到远程服务器 | | git push origin --tags | 将所有标签推送到远程服务器 | | git tag -d v1.4 | 删除本地的v1.4标签 | | git push origin --delete v1.4 | 删除远程服务器的v1.4标签 | ### Windows配置快捷命令 vi /etc/profile.d/aliases.sh ``` alias ga='git add' alias gd='git diff' alias gca='git commit -v -a' alias gcam='git commit -a -m' alias gca!='git commit -v -a --amend' alias gst='git status' alias gb='git branch' alias gba='git branch -a' alias gco='git checkout' alias gcm='git checkout master' alias gl='git pull' alias gp='git push' ``` ### 配置别名 ``` // git lg git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit" ```