git_git入门用法/获取帮助/客户端GUI操作git/在本地创建github上已有的分支(非主分支)/产看远程分支情况/所有分支情况
文章目录
git 入门用法和指南
git help
上网查资料之前,您不妨通过git help 来获取一些基础的帮助(当您阅读有困难的时候,才去上网搜)
git help 入门介绍(分门别类)
git help usage: git [--version] [--help] [-C <path>] [-c <name>=<value>] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] [--super-prefix=<path>] [--config-env=<name>=<envvar>] <command> [<args>] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink restore Restore working tree files rm Remove files from the working tree and from the index sparse-checkout Initialize and modify the sparse-checkout examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug diff Show changes between commits, commit and working tree, etc grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches commit Record changes to the repository merge Join two or more development histories together rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state switch Switch branches tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept. See 'git help git' for an overview of the system.
git help
介绍了几个模块,并指导用户如何利用git help中的那些模块来学习以及查阅某个命令
- git help tutorial
- 介绍了最为常用,最为基本的命令
- git help git 从另外的角度介绍git 运作系统
- 介绍了git help开屏的一大堆参数的各个选项的含义
- git help -a
- 介绍了git 的命令列表相对于
git help git
更加紧凑
- 介绍了git 的命令列表相对于
- git help -g
- 介绍了git 中所涉及的概念
- 以及git glossary(术语表)
例如
查阅git merge
的信息:
GIT-MERGE(1) Git Manual GIT-MERGE(1) NAME git-merge - Join two or more development histories together SYNOPSIS git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit] [--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]] [--[no-]allow-unrelated-histories] [--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...] git merge (--continue | --abort | --quit) DESCRIPTION Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch. This command is used by git pull to incorporate changes from another repository and can be used by hand to merge changes from one branch into another. Assume the following history exists and the current branch is "master": A---B---C topic / D---E---F---G master Then "git merge topic" will replay the changes made on the topic branch since it diverged from master (i.e., E) until its current commit (C) on top of master, and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes. A---B---C topic / \ D---E---F---G---H master The second syntax ("git merge --abort") can only be run after the merge has resulted in conflicts. git merge --abort will abort the merge process and try to reconstruct the pre-merge state. However, if there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), git merge --abort will in some cases be unable to reconstruct the original (pre-merge) changes. Therefore: Warning: Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict. The third syntax ("git merge --continue") can only be run after the merge has resulted in conflicts.
在本地创建github上已有的分支(非主分支),同时继承已有的记录,在该分支上工作
将github上的仓库的克隆仓库下来,一般只带下来主分支,而如果想要继续在某个非主分支上工作,您可以像这样做:
在本地产看github上的所有分支(包括非主分支)
或则,您可以通过git branch -r 来查看仅查询remote branch(远程分支)
客户端GUI操作git
- git自带GUI客户端
- Vscode 有相关可视化插件(git lens/git history/git graph等)
- GitHub客户端
- JetBrain IDE的可视化Git操作
- 其他客户端…
在本地创建github上已有的分支:
首先应当确保现场安全,否则报错(比如将现场add并且commit(但不一定要push)
然后,根据查到的远程仓库具有的分支,使用形如如下格式的命令
比如实例:(顺利的话)
git操作检查:
git log
(操作历史)
您可以checkout到对应的分支,在通过git log 来检查是否继承了github上的版本的工作记录git status
(最近的操作状态)
该部分实操:
可以使用fetch命令来实现
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」