当前位置: 首页 > news >正文

【Github】将本地仓库同步到github上

许久没有用GitHub了,怎么传仓库都忘记了。在这里记录一下
If you have a local folder on your machine and you want to transform it into a GitHub repository, follow the steps below:

1. Install Git (if not already installed)

Make sure you have Git installed on your machine. If not, download and install Git.

2. Create a GitHub Repository

Before pushing your local folder to GitHub, create a repository on GitHub:

  • Go to GitHub.
  • Log in to your account.
  • Click on the + sign at the top right and choose “New repository.”
  • Fill in your repository name and choose other settings like whether you want to initialize it with a README (for this tutorial, do not initialize with README, .gitignore, or license).
  • Click “Create repository.”

3. Initialize and Connect your Local Folder to the Repository

Now, navigate to your local folder using the command line (Terminal for macOS/Linux, Command Prompt or Git Bash for Windows) and execute the following commands:

# Navigate to your folder
cd path/to/your/folder# Initialize the folder as a Git repository
git init# Connect your local repository to your GitHub repository
git remote add origin https://github.com/your-username/your-repository-name.git

Make sure to replace your-username with your actual GitHub username and your-repository-name with the name of the repository you just created.

4. Push your Local Files to GitHub

Now, you’ll commit your local files and push them to GitHub:

# Add all files in the local directory to Git's staging area
git add .# Commit the changes
git commit -m "Initial commit"# Push the commit to the GitHub repository
git push -u origin master

(Note: If the default branch name is different than master, for instance main, replace master with the appropriate branch name in the git push command.)

After these steps, your local folder’s contents will now be in your GitHub repository!

总之就是即使有github desktop,也还是需要git bash操作才行。

http://www.lryc.cn/news/188501.html

相关文章:

  • c++视觉--通道分离,合并处理,在分离的通道中的ROI感兴趣区域里添加logo图片
  • python爬虫:多线程收集/验证IP从而搭建有效IP代理池
  • 阻塞队列以及阻塞队列的一个使用
  • kafka的请求处理机制
  • Linux系统管理:虚拟机Centos Stream 9安装
  • 5种排序算法
  • TCP/IP(七)TCP的连接管理(四)
  • LeetCode【84】柱状图中的最大矩形
  • C++:关于模拟实现vector和list中迭代器模块的理解
  • HTML 笔记 表格
  • 3.1 C/C++ 使用字符与指针
  • [代码学习]einsum详解
  • 女性必看——“黄体破裂”到底有多可怕?
  • colab切换目录的解决方案
  • 基于SSM的生活缴费系统的设计与实现
  • 【WebLogic】WebLogic 2023年7月补丁导致JVM崩溃的解决方案
  • 简单OpenSL ES学习
  • Linux网络编程- struct packet_mreq setsockopt()
  • C++学习day4
  • 从零学算法54
  • Logback日志框架使用详解以及如何Springboot快速集成
  • Nginx概念
  • vim基础指令(自用)
  • 【centos7安装ElasticSearch】
  • ElementPlus Switch 开关基础使用
  • Spring Boot:自定义注解--annotation
  • WIFI频段
  • Java的引用详解与示例
  • c++视觉处理---霍夫变换
  • el-table 边框颜色修改 简单有效!