• 【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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    (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操作才行。

  • 相关阅读:
    MySQL创建数据库、创建表操作和用户权限
    帮助团队成长是唯一的出路
    并查集的实现的应用
    使用 Nginx 和 SSL 访问 Python Flask 应用的教程
    【计算机网络】流量控制与可靠传输机制
    Phthon下载库函数
    【C++编程能力提升】
    贝叶斯优化的门控循环神经网络BO-GRU(时序预测)的Matlab实现
    1907_Arm Cortex-M3的基本了解
    【Android】Service 服务 生命周期原理最强解析
  • 原文地址:https://blog.csdn.net/zaza0_0/article/details/133754059