玖叶教程网

前端编程开发入门

版本控制工具git常用命令(git版本控制管理 pdf)

一些常用的 Git 命令:

1. git init: 初始化一个新的 Git 仓库。

2. git clone <repo>: 克隆一个远程仓库到本地。

3. git add <file>: 将文件添加到暂存区。

4. git commit -m "<message>": 提交暂存区的文件到本地仓库,并添加提交信息。

5. git push: 将本地仓库的提交推送到远程仓库。

6. git pull: 从远程仓库拉取最新的提交到本地。

7. git status: 查看当前仓库的状态,包括哪些文件已修改、哪些文件已添加到暂存区等。

8. git log: 查看提交历史,显示每次提交的详细信息。

9. git branch: 查看、创建或删除分支。

10. git checkout <branch>: 切换到指定的分支。

11. git merge <branch>: 将指定分支合并到当前分支。

12. git branch -d <branch>: 删除指定的分支。

13. git remote -v: 查看远程仓库的信息。

14. git tag <tagname>: 创建一个新的标签。

15. git push origin <tagname>: 将标签推送到远程仓库。

16. git show <tagname>: 查看标签的详细信息。

17. git fetch: 从远程仓库获取最新的提交和分支信息,但不会自动合并到本地分支。

18. git reset --hard <commit>: 重置本地仓库到指定的提交,会丢失之后的修改。

19. git stash: 临时保存当前的修改,以便在切换分支时不会丢失。

20. git stash apply: 应用之前保存的修改。

21. git stash drop: 丢弃之前保存的修改。

22. git stash list: 查看保存的修改列表。

23. git cherry-pick <commit>: 将指定的提交应用到当前分支。

24. git revert <commit>: 撤销指定的提交,并创建一个新的反提交。

一些常见的 Git 命令示例:

1. 初始化一个新的 Git 仓库:

git init

2. 克隆一个远程仓库到本地:

git clone <repository_url>

3. 将文件添加到暂存区:

git add <file1> <file2> ...

或者使用通配符添加所有修改的文件:

git add .

4. 提交暂存区的文件到本地仓库,并添加提交信息:

git commit -m "Commit message"

5. 将本地仓库的提交推送到远程仓库:

git push origin <branch_name>

6. 从远程仓库拉取最新的提交到本地:

git pull origin <branch_name>

7. 查看当前仓库的状态:

git status

8. 查看提交历史:

git log

9. 创建一个新的分支:

git branch <new_branch_name>

切换到新创建的分支:

git checkout <new_branch_name>

删除一个分支:

git branch -d <branch_name>

查看所有分支:

git branch -a

查看当前所在分支:

git branch --show-current

合并指定分支到当前分支:

git merge <branch_name>

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言