git基础与分支

git基础与分支

    • [git 基础](#git 基础)
    • [git 分支](#git 分支)

git 基础

bash 复制代码
# 1. 初始化 Git 仓库
git init

# 2. 配置用户名和邮箱(首次使用需要)
git config user.name "你的用户名"
git config user.email "你的邮箱"

# 3. 查看当前状态(确认 .gitignore 生效)
git status

# 4. 添加所有文件到暂存区
git add .

# 5. 查看哪些文件被忽略(可选)
git status --ignored

# 6. 提交代码
git commit -m "feat: 初始化项目 - 自由职通车"

# 7. 添加 Gitee 远程仓库(替换为你的仓库地址)
git remote add origin https://gitee.com/你的用户名/freework-app.git

# 8. 推送到master分支到 Gitee,-u绑定master分支(后续可直接git push,git pull)
git push -u origin master

git 分支

bash 复制代码
# 1. 创建并切换到 standalone 分支(本地App版本)
git checkout -b sa

# 查看当前分支,确认已切换
git branch

# 2. 切换回 master 分支
git checkout master

# 3. 创建并切换到 client-server 分支(C/S结构版本)
git checkout -b cs

# 查看所有分支
git branch -a

# 推送所有分支
git push origin --all