文章目录


一、创建分支

git提交本地项目到远程分支_git
git提交本地项目到远程分支_用户名_02

二、创建本地项目

mkdir docker-compose_file
cd docker-compose_file
git init
git config user.name '用户名'
git config user.email '邮箱'
mkdir yyjg
touch yyjg/docker-compose.yml
git add .
git commit -m 'test1'
git branch #查看本地仓库分支,发现会出现一个master的分支

git提交本地项目到远程分支_docker_03

三、配置远程仓库

git remote add origin   gitlab上项目地址

​origin 为远程仓库别名,方便后面使用​​​​获取gitlab上的项目地址​git提交本地项目到远程分支_docker_04

​git remote -v查看是否配置成功​

git提交本地项目到远程分支_git提交本地项目到远程分支_05

四、将代码提交到远程对应分支

push的时候会让输入用户名和密码,配置在本仓库push时不需要每次都输入用户名和密码

git config  credential.helper store

后面只需输入一次正确的用户名和密码即可

git push origin master:docker-compose_file