# 2309-homework **Repository Path**: qiushan1217/2309-homework ## Basic Information - **Project Name**: 2309-homework - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 41 - **Created**: 2024-01-15 - **Last Updated**: 2024-01-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 2309-homework #### 同步最新代码 1. 添加主仓库到 remote ```sh git remote add upstream git@gitee.com:Elvmx/2309-homework.git ``` 2. 拉取主仓库最新代码 ```sh git fetch upstream ``` 3. 合并主仓库代码 ```sh git merge upstream/master ``` 下载仓库内容:git clone 别人仓库https链接、ssh链接地址 git pull拉取新代码 git push 推送 git remote -v查看当前关联仓库名称 git 命令大全 git init 在当前文件夹下做 git 初始化,当前文件夹会出现一个隐藏的 .git 文件夹 git clone 克隆仓库 git config user.name 在当前仓库下做用户名的配置 git add . 将当前文件夹下的所有修改的文件都做暂存 git add 将具体文件做暂存 git commit -m "" 提交 git commit --amend 将最近一次的提交修改 message git commit 提交,会自动打开一个 vim 编辑器,在里面做 message 的说明 git status 查看当前仓库的状态 git log 查看当前仓库的所有提交记录,如果一屏放不下,使用 q 退出 git log -3 查看当前仓库的最新 3 次的提交记录 git diff 比较文件的变动 git reset --hard 将版本回退到 commitId git reset 将版本回退到 commitId,但是工作区不修改 git reflog 显示当前仓库的所有 git 操作记录 git branch 显示当前仓库的本地的所有分支 git branch -a 显示当前仓库的本地所有分支以及远程的所有分支 git branch 基于当前分支,创建一个新分支 git branch 基于 branchName 分支,创建一个新分支 git branch 基于 远程 remote 的 branchName 分支,创建一个新分支 git checkout -b or git switch -c 基于当前分支,创建一个新分支,且切换到该新分支 git checkout -b or git switch -c 基于 branchName 分支,创建一个新分支,且切换到该新分支 git checkout -b or git switch -c 基于 远程 remote 的 branchName 分支,创建一个新分支,且切换到该新分支 git checkout or git switch 切换到 name 分支, 分支存在,则直接切换 分支不存在, 远程有,则基于远程这一个创建并切换下来 远程没有,则报错 git merge 合并 branch 分支当当前分支上 git remote -v 显示当前仓库与远程的链接信息 git remote add 将 repo 远程仓库与本地仓库关联 git remote remove 将 remote 远程仓库与本地仓库解除关联 git remote rename 将 oldRemote 改名为 newRemote git fetch 将 remote 远程的一些信息(提交、分支、tag)给同步到本地。remote 默认值是 origin git push 将当前分支,推送到 remote 远程的 branch 分支上 git push --force 强制推送默认,慎用 git pull 将远程 remote 的分支拉趣到本地当前分支,且合并 git pull = git fetch + git merge git config --global user.name git config --global user.email 全局配置用户名与邮箱 【重要,安装好 git 之后第一件事就是处理它】 git tag 显示当前所有的 tag git tag 创建 tag git tag -d 删除该 tag git push 推送 tag 到远程 git push --tags 推送本地所有 tag 到远程