git 本地代码管理

简介

git 能实现本地代码多个更改版本的管理和导出。

首先复制好项目(参考 git clone 别人项目后正确的修改和同步操作 中的前三步)

实操

  1. 克隆原始项目
    首先,从远程仓库克隆项目到本地:

    bash 复制代码
    git clone https://github.com/libo-huang/eTag.git
    cd eTag
  2. 添加上游仓库
    将原始项目的远程仓库添加为上游仓库:

    bash 复制代码
    git remote add upstream https://github.com/libo-huang/eTag.git

    可以使用 git remote -v 命令查看远程仓库配置:

    bash 复制代码
    git remote -v
  3. 创建新分支
    在本地创建一个新的分支:

    bash 复制代码
    git checkout -b libo

    也可以使用哈希值创建新分支:git checkout -b libo <commit-hash>
    git log ---oneline 查看项目中所有的 commit 哈希值,使用q退出。
    git branch 查看本地所有分支。

  4. 修改和保存

    bash 复制代码
    # 切换分支
    git checkout libo
    
    # 修改添加与确认
    git add .   # 添加
    git commit -m 'xxx'  # 确认
    
    # 内容暂存与恢复
    git stash  # 暂存
    git stash list  # 查看暂存内容
    git stash apply  # 恢复
    
    # 复制备份分支:先复制切换好的分支文件到target-folder并进入
    cp -r . /path/to/target-folder
    cd /path/to/target-folder
    # 重置head到<commit-hash>
    git reset --hard <commit-hash>
相关推荐
极地星光5 小时前
从零到一搭建 **多仓库项目(Repo Manager 架构)** 完整步骤
git·架构
原来是猿6 小时前
进程间通信(三):命名管道
linux·服务器·网络·git
幸福从心动开始6 小时前
脱单不是拖,爱要主动说——写给还在“git commit -m ‘等缘分’”的程序员
git
弹简特9 小时前
【测试基础】11-软件测试之测试方案编写&测试报告编写&Git工具安装
git·功能测试
吴声子夜歌1 天前
TypeScript——泛型
前端·git·typescript
春日见1 天前
3三分彻底了解Git Graph极其应用
git
风.foxwho1 天前
jenkins使用 ED25519密钥 拉取Git 代码 配置
git·servlet·jenkins
ruanCat1 天前
前端工程化工具链从零配置:simple-git-hooks + lint-staged + commitlint
前端·git·代码规范
木子小喵1 天前
Git的使用介绍!超通俗!
git
coderYYY1 天前
git push报错Authentication failed for ‘xxx’也不会弹要求输入用户名密码的最终解决方法
前端·git·gitee·github