Kimi / Using git tool push a local repository to the remote repository

Created Sat, 26 Oct 2019 12:35:20 +0800 Modified Fri, 13 Jun 2025 03:34:05 +0000
319 Words

使用Git将本地仓库推送到远程仓库

A simple step to push a local code repository to the remote repository.

以前不喜欢用Git,现在东西都搬上代码仓库了,管理迭代效率极佳,不能不会哦。

————————————————————

* 适用于一般情况

1. 对于 git clone 的仓库

clone 到本地更新后,需要推送到服务器

  1. 添加项目文件

    git add .
    
  2. 添加描述

    git commit -m "更新/修改了什么"
    
  3. 推送到远端

    git push origin <分支>
    

    注:不要直接推送到 main 分支,后面确认没有问题再合并到 main 分支。

2. 对于新建仓库

先在服务器上新建仓库再执行推送

3. 常见问题

3.1 需要设置用户

git config --user.name "你的昵称"
git config --user.email "你的邮箱"

3.2 Git优先级

优先级:local > global > system

git config ( git config  --local ) > git config --global > git config --system

local:   仓库级别
global:  用户级别
system:  系统级别