windows下上传代码到gitlab服务器

版权声明:尊重他人劳动成果,转载请注明出处 https://blog.csdn.net/qq_41432935/article/details/81784512
  1. 安装windows下git
    安装完成后,鼠标右键git bash here
    初始化用户名和邮箱:
git config --global user.name "Hello"
git config --global user.email "[email protected]" 
  1. 输入账号密码登陆以后(假设你的账号是[email protected]),点“New Project”,这里设置工程名为example,创建工程之后网页会有提示: You won’t be able to pull or push project code via SSH until you add an SSH key to your profile 这时我们需要把刚才生成的公钥递交到服务器上,点击“add an SSH key”
    我们需要生成一对 Key(这里指密钥),然后才能通过加密的方式和服务器的代码库取得同步。现在运行C:\msysgit\msysgit\msys.bat,并执行以下命令:(注意请把[email protected]替换成你的账号)
$ ssh-keygen -t rsa -C "[email protected]"

git命令介绍

Git global setup

git config --global user.name "Hello"
git config --global user.email "[email protected]" 

Create a new repository 下载代码

git clone git@192.168.1.1:Roy/test.git #基于SSH
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder 上传本地代码到Git

cd existing_folder
git init 
git remote add origin git@192.168.1.1:Roy/test.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@192.168.1.1:Roy/test.git
git push -u origin --all
git push -u origin --tags

猜你喜欢

转载自blog.csdn.net/qq_41432935/article/details/81784512