# GitCommand **Repository Path**: vampirefyk/git-command ## Basic Information - **Project Name**: GitCommand - **Description**: git command line - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-30 - **Last Updated**: 2025-09-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Git_Command_Line git config --global user.name "SenseLo": Git全局配置_用户名 git config --global user.email "lnfuyuankai@126.com": Git全局配置_用户邮箱 工作区 -> 暂存区 -> 本地库 git init: 初始化Git仓库 touch README.md: 创建README文件 git remote add origin https://gitee.com/vampirefyk/git-command.git: 关联远程仓库 git add . :将未提交的代码 添加到暂存区 git add file_name: 文件添加到暂存区 git add --all: 全部文件添加到暂存区 git rm --cached file_name: 文件从暂存区回撤到工作区 git commit --allow -empty -m "空的" git commit -m [message]: 暂存区内容添加到本地仓库中 git commit --amend -m "撤回刚才的commit, 重新提交" git commit -a -m "msg_content": add + commit > 对已经存在仓库的文件有效, 新加入的文件无效.得先add . + commit git clone git_path: 克隆Git代码 git push origin r_branch_name: 推送到远程分支 git status: 查看工作区和暂存区的状态 git log: 查看git记录 git log --oneline --graph: 查看git记录 git log --oneline --author="CP_fuyuankai\|other_name": 查看git记录 git log --oneline --grep="Readme.md": 从commit信息中搜索关键字 分支相关命令行: git branch: 查看本地当前所在分支 git branch -r: 查看远程分支 git branch -m branch_name: 重名名分支名称 git branch -a: 查看所有分支 git checkout -b branch_name origin/r_branch_name: 拉取远程分支 并 分化一个新的分支到本地 git branch branch_name: 创新新的分支,并不切换 git checkout -b branche_name: 创建新的分支,并且切换 git branch -m | -M oldbranch newbranch: 重命名分支,如果newbranch名字已经存在,则需要使用-M强制重命名,否则,使用-m进行重命名。 git branch -d | -D -r branchname: 删除branchname分支,D表示强制删除 + -r 删除远程分支 git branch -v: 查看各个分支最后一次提交 git branch -- merged :查看哪些分支合并入当前分支 git branch no --merged :查看哪些分支未合并入当前分支 git fetch origin master:temp : 在本地新建一个temp分支,并将远程origin仓库的master分支代码下载到本地temp分支 git diff temp: 比较本地代码与刚刚从远程下载下来的代码的区别 git merge temp: 合并temp分支到本地的master分支