跳转至

Git,Vercel使用指南

Git 使用

基本 Git 命令

为使用 Git,开发人员使用特定命令来复制、创建、更改和合并代码。 这些命令可以直接从命令行执行,也可以使用 GitHub Desktop等应用程序执行。 以下是使用 Git 的一些常用命令:

git init 初始化一个全新的 Git 存储库并开始跟踪现有目录。 它在现有目录中添加一个隐藏的子文件夹,该子文件夹包含版本控制所需的内部数据结构。

git clone 创建远程已存在的项目的本地副本。 克隆包括项目的所有文件、历史记录和分支。

git add 暂存更改。 Git 跟踪对开发人员代码库的更改,但有必要暂存更改并拍摄更改的快照,以将其包含在项目的历史记录中。 此命令执行暂存,即该两步过程的第一部分。 暂存的任何更改都将成为下一个快照的一部分,并成为项目历史记录的一部分。 通过单独暂存和提交,开发人员可以完全控制其项目的历史记录,而无需更改其编码和工作方式。

git commit 将快照保存到项目历史记录中并完成更改跟踪过程。 简言之,提交就像拍照一样。 任何使用 git add 暂存的内容都将成为使用 git commit 的快照的一部分。

git status 将更改的状态显示为未跟踪、已修改或已暂存。

git branch 显示正在本地处理的分支。

git merge 将开发线合并在一起。 此命令通常用于合并在两个不同分支上所做的更改。 例如,当开发人员想要将功能分支中的更改合并到主分支以进行部署时,他们会合并。

git pull 使用远程对应项的更新来更新本地开发线。 如果队友已向远程上的分支进行了提交,并且他们希望将这些更改反映到其本地环境中,则开发人员将使用此命令。

git push 使用本地对分支所做的任何提交来更新远程存储库。

有关详细信息,请参阅 Git 命令的完整参考指南

Git 全局设置:

git config --global user.name "********"

git config --global user.email "********@***.com"

参考
1. Git
2. 玩转Git,需要记住那些命令
3. 将本地项目push到github上

参与现有存储库

# download a repository on GitHub to our machine
# Replace `owner/repo` with the owner and name of the repository to clone
git clone https://github.com/owner/repo.git

# change into the `repo` directory
cd repo

# create a new branch to store any new changes
git branch my-branch

# switch to that branch (line of development)
git checkout my-branch

# make changes, for example, edit `file1.md` and `file2.md` using the text editor

# stage the changed files
git add file1.md file2.md

# take a snapshot of the staging area (anything that's been added)
git commit -m "my snapshot"

# push changes to github
git push --set-upstream origin my-branch

启动新存储库并将其发布到 GitHub

首先,您需要在 GitHub 上创建一个新存储库。 有关详细信息,请参阅Hello World。 不要使用 README、.gitignore 或 License 文件初始化存储库。 这个空存储库将等待您的代码。

# create a new directory, and initialize it with git-specific functions
git init my-repo

# change into the `my-repo` directory
cd my-repo

# create the first file in the project
touch README.md

# git isn't aware of the file, stage it
git add README.md

# take a snapshot of the staging area
git commit -m "add README to initial commit"

git branch -M main

# provide the path for the repository you created on github
git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPOSITORY-NAME.git

# push changes to github
git push --set-upstream origin main

为 GitHub 的现有分支做出贡献

# change into the `repo` directory
cd repo

# update all remote tracking branches, and the currently checked out branch
git pull

# change into the existing branch called `feature-a`
git checkout feature-a

# make changes, for example, edit `file1.md` using the text editor

# stage the changed file
git add file1.md

# take a snapshot of the staging area
git commit -m "edit file1"

# push changes to github
git push

Vercel 使用