git命令笔记

不及物动词 其他 82

回复

共3条回复 我来回复
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    Git is a distributed version control system that allows multiple people to collaborate on a project and track changes made to files over time. This guide will provide a summary of some commonly used Git commands.

    1. Initialization:
    – `git init` – Initializes a new Git repository in the current directory.

    2. Cloning a repository:
    – `git clone ` – Creates a local copy of a remote repository.

    3. Adding and committing changes:
    – `git add ` – Adds a file to the staging area.
    – `git commit -m ` – Commits changes with a descriptive message.

    4. Branching:
    – `git branch` – Lists all branches in the repository.
    – `git branch ` – Creates a new branch.
    – `git checkout
    ` – Switches to a different branch.
    – `git merge
    ` – Merges changes from a branch into the current branch.

    5. Pulling and pushing changes:
    – `git pull` – Fetches and merges changes from a remote repository.
    – `git push` – Pushes local changes to a remote repository.

    6. Viewing changes:
    – `git status` – Shows the current status of the repository.
    – `git log` – Displays the commit history.
    – `git diff` – Shows the differences between files.

    7. Remote repositories:
    – `git remote` – Lists remote repositories.
    – `git remote add ` – Adds a new remote repository.
    – `git remote remove ` – Removes a remote repository.

    8. Undoing changes:
    – `git revert ` – Reverts a specific commit.
    – `git reset
    ` – Discards commits and resets the branch to a previous commit.
    – `git stash` – Stashes changes that are not ready to be committed.

    9. Tagging:
    – `git tag` – Lists all tags.
    – `git tag ` – Creates a new tag.
    – `git tag -d
    ` – Deletes a tag.

    10. Gitignore file:
    – `.gitignore` – Specifies files and directories to ignore.

    This is just a brief overview of some common Git commands. There are many more advanced commands and features available in Git.

    2年前 0条评论
  • 不及物动词的头像
    不及物动词
    这个人很懒,什么都没有留下~
    评论

    使用Git进行版本控制是开发人员的基本技能之一,下面是一些常用的Git命令的笔记:

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

    2. 克隆一个远程Git仓库到本地:
    “`
    git clone
    “`

    3. 添加文件到暂存区:
    “`
    git add
    “`

    4. 提交文件到仓库:
    “`
    git commit -m “commit message”
    “`

    5. 查看文件状态:
    “`
    git status
    “`

    6. 查看当前分支的提交历史:
    “`
    git log
    “`

    7. 切换到指定分支:
    “`
    git checkout
    “`

    8. 创建一个新分支:
    “`
    git branch
    “`

    9. 合并指定分支到当前分支:
    “`
    git merge
    “`

    10. 拉取远程仓库的更新:
    “`
    git pull
    “`

    11. 推送本地仓库的更新到远程仓库:
    “`
    git push
    “`

    12. 回退到上一个提交:
    “`
    git revert HEAD
    “`

    13. 丢弃工作区的修改:
    “`
    git checkout —
    “`

    14. 存储当前修改而不提交:
    “`
    git stash save
    “`

    15. 恢复之前存储的修改:
    “`
    git stash pop
    “`

    16. 查看远程仓库的信息:
    “`
    git remote -v
    “`

    17. 添加远程仓库:
    “`
    git remote add
    “`

    18. 删除远程仓库:
    “`
    git remote remove
    “`

    以上是一些常见的Git命令,可以帮助开发人员进行版本控制和协作开发。不同的命令组合可以实现更复杂的操作,使用Git还有很多其他的功能和命令,可以通过查阅Git官方文档了解更多。记住这些命令并熟练使用它们将会极大地提高开发效率。

    2年前 0条评论
  • fiy的头像
    fiy
    Worktile&PingCode市场小伙伴
    评论

    一、Git的基本原理和概念

    1.1 Git的基本原理
    Git是一种分布式版本控制系统,采用了一种称为“快照”的方式来存储文件的变化。每次提交都会创建一个新的快照,并记录之前的快照的引用。

    1.2 Git的基本概念
    – 仓库(Repository):保存项目的所有文件和历史记录。
    – 提交(Commit):保存项目的某个版本,包含了一个快照和相关的提交信息。
    – 分支(Branch):是指向提交的引用,每个分支都可以有多个提交。
    – 主分支(Master):默认的主要分支。
    – 远程仓库(Remote Repository):存储在网络上的仓库,可以与其他开发者共享。

    二、Git的基本操作流程

    2.1 初始化仓库
    在一个空文件夹中初始化一个Git仓库,使用命令:`git init`。

    2.2 添加文件
    将文件添加到仓库的暂存区,使用命令:`git add `。

    2.3 提交文件
    将暂存区的文件提交到仓库的历史记录中,使用命令:`git commit -m “commit message”`。

    2.4 查看仓库状态
    查看当前仓库的文件状态,使用命令:`git status`。

    2.5 查看提交历史
    查看仓库的提交历史,使用命令:`git log`。

    2.6 创建分支
    在当前提交上创建一个新的分支,使用命令:`git branch `。

    2.7 切换分支
    切换到指定的分支,使用命令:`git checkout `。

    2.8 合并分支
    将指定分支的更改合并到当前分支,使用命令:`git merge `。

    2.9 拉取远程仓库
    从远程仓库中拉取最新的代码,使用命令:`git pull`。

    2.10 推送到远程仓库
    将本地的更改推送到远程仓库,使用命令:`git push`。

    三、Git的常用命令详解

    3.1 git init
    初始化一个新的Git仓库。在当前目录中创建一个新的.git子目录,用来保存版本库的相关信息。

    3.2 git add
    将文件添加到暂存区,准备提交到仓库。

    – 添加单个文件:`git add `
    – 添加多个文件:`git add …`
    – 添加所有文件:`git add .`

    3.3 git commit
    将暂存区的文件提交到仓库的历史记录中。

    – 提交当前暂存区的文件:`git commit -m “commit message”`
    – 提交指定文件并附带说明:`git commit -m “commit message”`

    3.4 git status
    查看当前仓库的文件状态,包括新增、修改、删除等。

    3.5 git log
    查看当前仓库的提交历史。

    – 查看提交历史(仅显示提交信息):`git log –oneline`
    – 查看提交历史(显示详细信息):`git log`

    3.6 git branch
    用于创建、查看和删除分支。

    – 创建分支:`git branch `
    – 查看分支:`git branch`
    – 删除分支:`git branch -d
    `

    3.7 git checkout
    用于切换分支或者恢复文件。

    – 切换分支:`git checkout `
    – 恢复文件到最新提交:`git checkout — `

    3.8 git merge
    用于将指定分支的更改合并到当前分支。

    – 合并指定分支:`git merge `

    3.9 git pull
    用于从远程仓库中拉取最新的代码。

    – 拉取远程仓库的最新代码:`git pull`

    3.10 git push
    用于将本地的更改推送到远程仓库。

    – 推送本地更改到默认远程仓库:`git push`
    – 推送本地更改到指定远程仓库:`git push `

    2年前 0条评论
注册PingCode 在线客服
站长微信
站长微信
电话联系

400-800-1024

工作日9:30-21:00在线

分享本页
返回顶部