git主要命令

初始化仓库

1
git init

克隆仓库

1
git clone <repository_url>

添加文件到暂存区

1
git add <file_name>

提交更改

1
git commit -m "Commit message"

查看状态

1
git status

查看提交历史

1
git log

推送更改到远程仓库

1
git push <remote_name> <branch_name>

添加远程仓库地址:

1
git remote add origin <repository_url>

<repository_url> 是别人的仓库地址。可以使用 git remote -v 来确认远程仓库是否添加成功。

拉取最新代码:

1
git pull origin <branch_name>

<branch_name> 是你想要拉取代码的分支名。这个命令会从远程仓库(origin)拉取指定分支的最新代码到你的本地仓库。

这样就能够将别人仓库中的最新代码更新到你的本地工作环境中。


git主要命令
https://zbshlv.fun/2023/12/27/git主要命令/
作者
知白守黑
发布于
2023年12月27日
许可协议