玖叶教程网

前端编程开发入门

掌握这26个常用Git命令就够了(常用的git命令)

Git,作为一个开源的分布式版本控制系统,无疑在现代软件开发中扮演着不可或缺的角色。它由Linux之父Linus Torvalds在2005年创造,最初的目的是为了更高效地管理Linux内核开发。如今,Git已经成为全球最受欢迎的版本控制系统之一,它的设计哲学强调性能、灵活性和安全性。

下面列出了工作中最常用的Git命令列表,通过学习这些常用的GIT命令,足以应对日常工作中遇到的问题

Git 命令列表:

  1. git init:

初始化一个新的 Git 存储库。

git init

2. git clone:

在本地计算机上创建远程存储库的副本。

git clone <repository_url>

3. git add:

将工作目录中的更改添加到暂存区域。

git add <file_name>

添加所有更改

git add .

4. git commit:

将暂存区里的改动给提交到本地的版本库。

git commit -m "Commit message"

5.git status:

用于显示版本库和暂存区的状态。它允许我们看到被追踪的、未被追踪的文件和变化。

git status

6. git pull:

从远程存储库获取更改并将其合并到当前分支中。

git pull

7. git push:

将更改从本地存储库推送到远程存储库。

git push

8. git branch:

列出现有分支并突出显示当前分支。

git branch

创建一个新分支。

git branch <branch_name>

9. git checkout:

切换到指定的分支。

git checkout <branch_name>

10. git merge:

将一个分支的更改合并到另一个分支。

git merge <branch_name>

11. git log:

显示提交日志。

git log

12. git remote:

列出远程存储库。

git remote -v

添加远程存储库。

git remote add <remote_name> <repository_url>

13. git fetch:

从远程存储库获取更改,但不会自动合并它们。

git fetch

14. git diff:

显示提交、分支或工作目录之间的更改。

git diff

15. git reset:

将索引和工作目录重置为指定状态。

git reset <commit_hash>

16. git revert:

创建一个新的提交,撤消先前提交中所做的更改。

git revert <commit_hash>

17. git remote remove:

删除远程存储库。

git remote remove <remote_name>

18. git stash:

暂时保存尚未准备好提交的更改。

git stash

19. git stash pop

取消保存在存储列表中的更改(恢复最新的进度到工作区)。

git stash pop

20.git blame:

显示文件中每一行代码最后是谁修改的。

git blame <file_name>

21. git remote update:

从远程存储库获取更新但不合并它们。

git remote update

22. git branch -d:

删除本地分支。

git branch -d <branch_name>

23. git branch -m:

重命名当前分支。

git branch -m <new_branch_name>

24. git remote show:

显示有关远程存储库的信息。

git remote show <remote_name>

25. git remote prune:

删除远程存储库中不存在的跟踪分支。

git remote prune <remote_name>

26. git show:

显示特定对象的提交、标签或文件信息。

git show <commit_hash>

发表评论:

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