广州网站建设公司推荐昌做网站
目录
- Git常用命令
 - 1. git init (初始化一个新的Git仓库)
 - 2. git clone [url] (克隆远程仓库到本地计算机)
 - 3. git status (查看当前工作区的状态)
 - 4. git add [file] (将文件添加到暂存区)
 - 5. git commit -m "commit message" (提交暂存区中的更改)
 - 6. git log (查看提交历史记录)
 - 7. git diff (查看工作区与上次提交之间的代码差异)
 - 8. git remote -v (查看已配置的远程仓库及其URL)
 - 9. git remote add [remote-name] [url] (添加一个新的远程仓库)
 - 10. git push [remote-name] [branch-name] ( 将本地分支推送到远程仓库)
 - 11. git pull [remote-name] [branch-name] (从远程仓库拉取最新的更改并合并到本地分支)
 - 12. git fetch [remote-name] (从远程仓库获取最新的更改)
 - 13. git branch (查看本地分支列表)
 - 14. git checkout [branch-name] ( 切换到另一个分支或恢复工作树文件)
 - 15. git merge [branch-name] (将指定的分支合并到当前分支)
 
Git常用命令
1. git init (初始化一个新的Git仓库)
在项目目录中运行此命令,以便开始跟踪文件更改。
git init
 
2. git clone [url] (克隆远程仓库到本地计算机)
将[url]替换为远程仓库的URL。
git clone https://github.com/user/repo.git
 
3. git status (查看当前工作区的状态)
查看已修改但未提交的文件。
git status
 
4. git add [file] (将文件添加到暂存区)
将[file]替换为要添加的文件名。如果使用git add .,则会添加所有更改过的文件。
git add file.txt
 
5. git commit -m “commit message” (提交暂存区中的更改)
附上一条描述性的提交信息。
git commit -m "Add new feature"
 
6. git log (查看提交历史记录)
git log
 
7. git diff (查看工作区与上次提交之间的代码差异)
git diff
 
8. git remote -v (查看已配置的远程仓库及其URL)
git remote -v
 
9. git remote add [remote-name] [url] (添加一个新的远程仓库)
将[remote-name]替换为远程仓库的名称,如origin,将[url]替换为远程仓库的URL。
git remote add origin https://github.com/user/repo.git
 
10. git push [remote-name] [branch-name] ( 将本地分支推送到远程仓库)
将[remote-name]替换为远程仓库的名称,如origin,将[branch-name]替换为要推送的分支名称,如main。
git push origin main
 
11. git pull [remote-name] [branch-name] (从远程仓库拉取最新的更改并合并到本地分支)
将[remote-name]替换为远程仓库的名称,如origin,将[branch-name]替换为要拉取的分支名称,如main。
git pull origin main
 
12. git fetch [remote-name] (从远程仓库获取最新的更改)
不进行合并。将[remote-name]替换为远程仓库的名称,如origin。
git fetch origin
 
13. git branch (查看本地分支列表)
git branch
 
14. git checkout [branch-name] ( 切换到另一个分支或恢复工作树文件)
将[branch-name]替换为要切换到的分支名称。
git checkout feature-branch
 
15. git merge [branch-name] (将指定的分支合并到当前分支)
将[branch-name]替换为要合并的分支名称。
git merge feature-branch
