更新项目
当自己的本地项目与 远程的github 的仓库已经建立远程连接时, 则直接按照下面的步骤,
将本地的项目代码更新到远程仓库。
# Stage the resolved file
git add README.md <file1> <file2>
# To stage all changes:
git add .
# Commit the merge
git commit -m "Resolved merge conflict in README.md"
# Push the changes
git push origin main
如果在此之前, 自己的本地仓库并没有与远程的仓库建立连接时, 则先需要按照下面的步骤进行连接建立。
1. 建立连接
由于github在 2021 年开始, 取消使用密码登录的方式, 因此 这里推荐使用第二种 通过ssh 连接的方式,进行登录。
The error occurs because GitHub no longer supports password-based authentication for HTTPS URLs (as of August 13, 2021). Instead, you need to use one of the following authentication methods:
Option 1: Use a Personal Access Token (PAT)
GitHub now requires a Personal Access Token (PAT) instead of a password for HTTPS authentication.
Steps:
-
Generate a PAT:
- Go to your GitHub account settings: GitHub Tokens.
- Click Generate new token.
- Select the appropriate scopes (e.g.,
repo
for full control of private repositories). - Generate the token and copy it (you won’t be able to see it again).
-
Use the PAT for Authentication:
- When prompted for a password, paste the PAT instead of your GitHub password.
Example:
Username for 'https://github.com': your_account Password for 'https://xxxxx@github.com': <paste-your-PAT-here>
Option 2: Use SSH Authentication
SSH is a more secure and convenient way to authenticate with GitHub.
Steps:
- Generate an SSH Key (if you don’t already have one):
- Run the following command in your terminal:
ssh-keygen -t ed25519 -C "your_email@example.com"
- Press Enter to accept the default file location and passphrase (optional).
- Run the following command in your terminal:
The command ssh-keygen -t ed25519 -C "your_email@example.com"
is used to generate a new SSH key pair for secure authentication with remote servers, such as GitHub. Let’s break down the command and its components:
Command Breakdown
-
ssh-keygen
:- This