Git 安装后代码拉去和提取全流程(亲测使用有效)
本地有项目要通过Git上传到某某云或者服务器上:
详细操作步骤
1. 配置Git用户信息(如果尚未配置)
git config --global user.name "你的姓名" git config --global user.email "你的邮箱@example.com"
2. 进入项目目录并初始化(可以在本地项目路径下打开Git bash )
cd /path/to/your/project
git init
3. 创建或检查 .gitignore 文件
# 创建忽略文件列表,避免上传不必要的文件
touch .gitignore 示例 .gitignore 内容: # 编译输出 node_modules/ dist/ build/ *.log # 环境变量 .env .config/ # IDE相关 .vscode/ .idea/ *.swp *.swo
4. 添加文件并提交
git add . git commit -m "%P25GSW1YF0056-379 给代码添加解释说明"
5. 连接远程仓库
# 替换为你的研发云仓库地址
git remote add origin <你的研发云仓库HTTPS或SSH地址(克隆/下载位置获取链接)>
6. 推送代码
# 设置默认分支并推送
git branch -M master
git push -u origin master
7.强制推送
# 仅限第一次提交代码是可强制推送(这会覆盖远程仓库的内容)
git push -f origin master
8.后续仓库使用日常
# 查看状态 git status
# 添加更改的文件 git add . # 提交更改 git commit -m "描述你的更改" # 推送到远程仓库 git push
浙公网安备 33010602011771号