国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解

這篇具有很好參考價(jià)值的文章主要介紹了Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

目錄

1. 背景

2. git簡介

3. git常用指令

????????3.1 clone

????????3.2 checkout

????????3.3 branch

????????3.4 add

????????3.5 commit

????????3.6 push

????????3.7 pull

4. 結(jié)語


1. 背景

  • 工具名稱:git
  • 應(yīng)用場景:git最主要的應(yīng)用場景是用于管理和控制代碼的版本。開發(fā)人員可以使用Git來跟蹤代碼的變化,記錄每次的提交,并輕松地回滾到之前的版本。git還提供了分支管理功能,可以方便地創(chuàng)建、切換和合并分支,使得團(tuán)隊(duì)成員可以并行開發(fā)不同的功能或修復(fù)bug。
  • 與其他版本控制系統(tǒng)的區(qū)別:與集中式版本控制系統(tǒng)(如SVN)相比,Git具有更高的性能、更強(qiáng)大的分支管理和更好的代碼合并能力。

本文將對git的幾個(gè)基本操作進(jìn)行詳細(xì)講解,幫助大家從零開始學(xué)習(xí)git的用法。

2. git簡介

?? git簡單來說就是代碼版本控制系統(tǒng),通過他可以進(jìn)行多人開發(fā)同一個(gè)項(xiàng)目然后講每個(gè)人的代碼塊合并完成一個(gè)大項(xiàng)目,還能控制代碼版本記錄等。官方文檔:https://git-scm.com/docs

git四個(gè)區(qū)域:

  1. 工作區(qū):處理工作的區(qū)域(即做項(xiàng)目打代碼的區(qū)域)。

  2. 暫存區(qū):已完成的工作臨時(shí)存放區(qū)域,等待被提交。

  3. 本地倉庫:存放數(shù)據(jù)的地方,但是還在本機(jī)上,若電腦存儲(chǔ)空間損壞還是會(huì)造成代碼消失。

  4. Git遠(yuǎn)程倉庫:最終的存放區(qū)域,即遠(yuǎn)程服務(wù)器,電腦存儲(chǔ)空間損壞也不影響遠(yuǎn)程倉庫數(shù)據(jù)。Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解,Git && CI/CD教學(xué)專欄,git,github

git四個(gè)狀態(tài):

  1. 未跟蹤(Untracked):文件沒有加入到git庫中,不參與版本控制,使用git add變?yōu)闀捍妗?/p>

  2. 已暫存(Staged):表示對已修改文件的當(dāng)前版本做了標(biāo)記,使之包含在下次提交的列表。

  3. 已修改(Modified):表示修改了文件,但還沒將修改的結(jié)果放到暫存區(qū)。

  4. 已提交(Unmodified):表示文件已經(jīng)安全地保存在本地Git倉庫。

    Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解,Git && CI/CD教學(xué)專欄,git,github

    3. git常用指令

    3.1 clone

    git clone [--template=<template-directory>]
    	  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
    	  [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
    	  [--dissociate] [--separate-git-dir <git-dir>]
    	  [--depth <depth>] [--[no-]single-branch] [--no-tags]
    	  [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
    	  [--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
    	  [--filter=<filter> [--also-filter-submodules]] [--] <repository>
    	  [<directory>]

    官網(wǎng)原文:

    Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch --remotes), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.

    After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).

    This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

    中文翻譯:

    將倉庫克隆到一個(gè)新創(chuàng)建的目錄中,為克隆倉庫中的每個(gè)分支創(chuàng)建遠(yuǎn)程跟蹤分支(可以使用git branch --remotes查看),并創(chuàng)建并切換到一個(gè)從克隆倉庫當(dāng)前活動(dòng)分支分叉出來的初始分支。 克隆完成后,執(zhí)行簡單的git fetch命令(不帶參數(shù))將更新所有遠(yuǎn)程跟蹤分支,而執(zhí)行g(shù)it pull命令(不帶參數(shù))將額外將遠(yuǎn)程主分支合并到當(dāng)前主分支中(除非使用了"--single-branch"選項(xiàng);詳見下文)。 這個(gè)默認(rèn)配置是通過在refs/remotes/origin下創(chuàng)建對遠(yuǎn)程分支頭的引用,并初始化remote.origin.url和remote.origin.fetch配置變量來實(shí)現(xiàn)的。

    例程說明:將特定倉庫里面的所有文件復(fù)制到本地,以github為例,我們首先在github上面找到一個(gè)想要的工程的鏈接,然后在界面上獲取到工程的ssh地址

    git@github.com:FreeRTOS/FreeRTOS-Kernel.git

    Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解,Git &amp;&amp; CI/CD教學(xué)專欄,git,github

?在powershell中輸入如下指令

git clone git@github.com:FreeRTOS/FreeRTOS-Kernel.git
cd .\FreeRTOS-Kernel\
ls

?運(yùn)行結(jié)果

PS D:\> git clone git@github.com:FreeRTOS/FreeRTOS-Kernel.git
Cloning into 'FreeRTOS-Kernel'...
remote: Enumerating objects: 173717, done.
remote: Counting objects: 100% (1435/1435), done.
remote: Compressing objects: 100% (682/682), done.
remote: Total 173717 (delta 809), reused 1224 (delta 669), pack-reused 172282
Receiving objects: 100% (173717/173717), 115.61 MiB | 65.00 KiB/s, done.

Resolving deltas: 100% (124658/124658), done.
PS D:\> cd .\FreeRTOS-Kernel\
PS D:\FreeRTOS-Kernel> ls


    目錄: D:\FreeRTOS-Kernel


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2024/4/2     15:56                .github
d-----          2024/4/2     15:56                examples
d-----          2024/4/2     15:56                include
d-----          2024/4/2     15:56                portable
-a----          2024/4/2     15:56            353 .git-blame-ignore-revs
-a----          2024/4/2     15:56             15 .gitattributes
-a----          2024/4/2     15:56            396 .gitmodules
-a----          2024/4/2     15:56          20038 CMakeLists.txt
-a----          2024/4/2     15:56          17807 croutine.c
-a----          2024/4/2     15:56            691 cspell.config.yaml
-a----          2024/4/2     15:56          36597 event_groups.c
-a----          2024/4/2     15:56            155 GitHub-FreeRTOS-Kernel-Home.url
-a----          2024/4/2     15:56         169900 History.txt
-a----          2024/4/2     15:56           1055 LICENSE.md
-a----          2024/4/2     15:56          10221 list.c
-a----          2024/4/2     15:56             96 manifest.yml
-a----          2024/4/2     15:56           4869 MISRA.md
-a----          2024/4/2     15:56         130682 queue.c
-a----          2024/4/2     15:56            145 Quick_Start_Guide.url
-a----          2024/4/2     15:56           7210 README.md
-a----          2024/4/2     15:56          72373 stream_buffer.c
-a----          2024/4/2     15:56         359564 tasks.c
-a----          2024/4/2     15:56          57909 timers.c


PS D:\FreeRTOS-Kernel>

3.2 checkout

git checkout [-q] [-f] [-m] [<branch>]
git checkout [-q] [-f] [-m] --detach [<branch>]
git checkout [-q] [-f] [-m] [--detach] <commit>
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new-branch>] [<start-point>]
git checkout [-f] <tree-ish> [--] <pathspec>…?
git checkout [-f] <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>…?
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…?]

官網(wǎng)原文:

Updates files in the working tree to match the version in the index or the specified tree. If no pathspec was given, git checkout will also update HEAD to set the specified branch as the current branch.

中文翻譯:

將工作樹中的文件更新為與索引或指定的樹版本相匹配。如果沒有指定路徑規(guī)范(pathspec),git checkout命令還會(huì)將HEAD更新為將指定分支設(shè)置為當(dāng)前分支。

例程說明:切換分支或恢復(fù)已被修改的文件

Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解,Git &amp;&amp; CI/CD教學(xué)專欄,git,github

在剛才的界面上,點(diǎn)擊分支的圖標(biāo),選擇一個(gè)已有分支 smp,然后在powershell執(zhí)行以下命令

git checkout smp
git branch

運(yùn)行結(jié)果

PS D:\FreeRTOS-Kernel> git checkout smp
Switched to a new branch 'smp'
branch 'smp' set up to track 'origin/smp'.
PS D:\FreeRTOS-Kernel> git branch
  main
* smp
PS D:\FreeRTOS-Kernel>

下面我們可以創(chuàng)建一個(gè)屬于自己的開發(fā)分支

git checkout -b dev/my_branch
git branch

?運(yùn)行結(jié)果

PS D:\FreeRTOS-Kernel> git checkout -b dev/my_branch
Switched to a new branch 'dev/my_branch'
PS D:\FreeRTOS-Kernel> git branch
* dev/my_branch
  main
  smp
PS D:\FreeRTOS-Kernel>

3.3 branch

git branch [--color[=<when>] | --no-color] [--show-current]
	[-v [--abbrev=<n> | --no-abbrev]]
	[--column[=<options>] | --no-column] [--sort=<key>]
	[--merged [<commit>]] [--no-merged [<commit>]]
	[--contains [<commit>]] [--no-contains [<commit>]]
	[--points-at <object>] [--format=<format>]
	[(-r | --remotes) | (-a | --all)]
	[--list] [<pattern>…?]
git branch [--track[=(direct|inherit)] | --no-track] [-f]
	[--recurse-submodules] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…?
git branch --edit-description [<branchname>]

官網(wǎng)原文:

If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted in green and marked with an asterisk. Any branches checked out in linked worktrees will be highlighted in cyan and marked with a plus sign. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches.

With a -d or -D option, <branchname> will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted.

Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again.

中文翻譯:

如果使用--list選項(xiàng),或者沒有非選項(xiàng)參數(shù),將列出現(xiàn)有的分支;當(dāng)前分支將以綠色高亮顯示,并帶有一個(gè)星號(hào)。在鏈接的工作樹中檢出的分支將以青色高亮顯示,并帶有一個(gè)加號(hào)。選項(xiàng)-r將列出遠(yuǎn)程跟蹤分支,選項(xiàng)-a顯示本地和遠(yuǎn)程分支。

使用-d或-D選項(xiàng),<branchname>將被刪除??梢灾付ǘ鄠€(gè)要?jiǎng)h除的分支。如果分支當(dāng)前具有reflog,則還將刪除reflog。

使用-r和-d選項(xiàng)一起刪除遠(yuǎn)程跟蹤分支。請注意,只有在遠(yuǎn)程倉庫中不再存在這些分支,或者如果配置了git fetch不再獲取它們時(shí),才有意義刪除遠(yuǎn)程跟蹤分支。

例程說明:在前面的操作中一直使用到的git branch指令,就是用來列舉、創(chuàng)建和刪除分支。前面已經(jīng)用git checkout -b的指令創(chuàng)建了分支,下面我們將試一下刪除指令,要注意的是,我們刪除分支前,需要先checkout到其他分支。

?在powershell中輸入如下指令

git branch
git checkout main
git branch -D dev/my_branch
git branch

運(yùn)行結(jié)果

PS D:\FreeRTOS-Kernel> git branch
* dev/my_branch
  main
  smp
PS D:\FreeRTOS-Kernel> git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
PS D:\FreeRTOS-Kernel> git branch -D dev/my_branch
Deleted branch dev/my_branch (was 81c623212).
PS D:\FreeRTOS-Kernel> git branch
* main
  smp
PS D:\FreeRTOS-Kernel>

3.4 add

git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
	  [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse]
	  [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]
	  [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]]
	  [--] [<pathspec>…?]

官網(wǎng)原文:

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.

The "index" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working tree, and before running the commit command, you must use the add command to add any new or modified files to the index.

This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index.

The git status command can be used to obtain a summary of which files have changes that are staged for the next commit.

The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option.

中文翻譯:

該命令使用工作樹中當(dāng)前的內(nèi)容更新索引,以準(zhǔn)備將內(nèi)容暫存至下一次提交。通常,它會(huì)將現(xiàn)有路徑的當(dāng)前內(nèi)容作為整體添加到索引中,但使用某些選項(xiàng)時(shí),也可以僅將部分工作樹文件的更改應(yīng)用于添加的內(nèi)容,或者移除工作樹中不再存在的路徑。

"索引"保存著工作樹內(nèi)容的快照,而正是這個(gè)快照被視為下一次提交的內(nèi)容。因此,在對工作樹進(jìn)行任何更改之后,在運(yùn)行提交命令之前,必須使用add命令將任何新的或修改過的文件添加到索引中。 在提交之前,可以多次執(zhí)行此命令。它僅在運(yùn)行add命令時(shí)添加指定文件的內(nèi)容;如果希望將后續(xù)更改包含在下一次提交中,則必須再次運(yùn)行g(shù)it add命令,將新的內(nèi)容添加到索引中。

可以使用git status命令獲取一個(gè)概要,其中列出了哪些文件具有已暫存的更改,準(zhǔn)備提交至下一次提交。 默認(rèn)情況下,git add命令不會(huì)添加被忽略的文件。如果在命令行上明確指定了任何被忽略的文件,git add將失敗,并顯示被忽略的文件列表。Git通過目錄遞歸或文件名通配符(在Shell之前引用通配符)進(jìn)行的遞歸會(huì)自動(dòng)忽略被忽略的文件??梢允褂?f(force)選項(xiàng)強(qiáng)制git add命令添加被忽略的文件。

例程說明:將文件內(nèi)容添加到索引中,當(dāng)本地的文件有改動(dòng)時(shí),需要把最新的文件內(nèi)存暫存到下一次提交中。比如文件夾里面多出了一個(gè)test.md文件時(shí),我們就可以用add命令來增加。

?在powershell中輸入如下指令

touch test.md
git status
git add .
git status

運(yùn)行結(jié)果

PS D:\FreeRTOS-Kernel> touch test.md
PS D:\FreeRTOS-Kernel> git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.md

nothing added to commit but untracked files present (use "git add" to track)
PS D:\FreeRTOS-Kernel> git add .
PS D:\FreeRTOS-Kernel> git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   test.md

PS D:\FreeRTOS-Kernel>

3.5 commit

git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
	   [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]
	   [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
	   [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
	   [--date=<date>] [--cleanup=<mode>] [--[no-]status]
	   [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]
	   [(--trailer <token>[(=|:)<value>])…?] [-S[<keyid>]]
	   [--] [<pathspec>…?]

官網(wǎng)原文:

Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point to it (unless no branch is associated with the working tree, in which case HEAD is "detached" as described in git checkout

中文翻譯:

創(chuàng)建一個(gè)新的提交,其中包含索引的當(dāng)前內(nèi)容和給定的日志消息,用于描述更改。新的提交是HEAD的直接子節(jié)點(diǎn),通常是當(dāng)前分支的尖端,并且分支會(huì)更新為指向它(除非工作樹沒有關(guān)聯(lián)的分支,此時(shí)HEAD會(huì)像git-checkout[1]中描述的那樣“分離”)。

例程說明:將更改記錄到本地倉庫中,最常使用的就是 git commit -m “commit Message(自定義)”


?在powershell中輸入如下指令

git status
git commit -m "Add Test Commit message"
git log

運(yùn)行結(jié)果如下

PS D:\FreeRTOS-Kernel> git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   test.md

PS D:\FreeRTOS-Kernel> git commit -m "Add Test Commit message"
[main 71e4ccb03] Add Test Commit message
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.md
PS D:\FreeRTOS-Kernel> git log
commit 71e4ccb03366316ba3a497f9d27c687f922c7934 (HEAD -> main)
Author: boxiong <zhaoboxiong@xyl.cn>
Date:   Tue Apr 2 16:05:43 2024 +0800

    Add Test Commit message

commit 52ee9faa72f2f67f04752c9d89b7b48c804bfa66 (origin/main, origin/HEAD)
Author: Soren Ptak <ptaksoren@gmail.com>
Date:   Thu Mar 28 22:37:38 2024 -0700

3.6 push

git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
	   [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-q | --quiet] [-v | --verbose]
	   [-u | --set-upstream] [-o <string> | --push-option=<string>]
	   [--[no-]signed|--signed=(true|false|if-asked)]
	   [--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]]
	   [--no-verify] [<repository> [<refspec>…?]]

官網(wǎng)原文:

Updates remote refs using local refs, while sending objects necessary to complete the given refs.

When the command line does not specify where to push with the <repository> argument, branch.*.remote configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to origin.

When neither the command-line nor the configuration specifies what to push, the default behavior is used, which corresponds to the simple value for push.default: the current branch is pushed to the corresponding upstream branch, but as a safety measure, the push is aborted if the upstream branch does not have the same name as the local one.

中文翻譯:

使用本地引用更新遠(yuǎn)程引用,同時(shí)發(fā)送完成給定引用所需的對象。?

當(dāng)命令行中的<repository>參數(shù)沒有指定推送的位置時(shí),會(huì)查詢當(dāng)前分支的branch.*.remote配置來確定推送的位置。如果配置缺失,則默認(rèn)為origin。當(dāng)命令行和配置都沒有指定要推送的內(nèi)容時(shí),將使用默認(rèn)行為,即對應(yīng)于push.default的簡單值:將當(dāng)前分支推送到相應(yīng)的上游分支,但為了安全起見,如果上游分支的名稱與本地分支不同,推送將被中止。

?例程說明:將內(nèi)容同步到遠(yuǎn)程倉庫中,最常用的就是git push origin HEAD

?在powershell中輸入如下指令

git push origin HEAD

由于我們沒有目標(biāo)倉庫的push權(quán)限,push命令將被拒絕,關(guān)于ssh訪問權(quán)限的獲取我們將在下一篇文章中進(jìn)行詳細(xì)講解。

PS D:\FreeRTOS-Kernel> git push origin HEAD
ERROR: Permission to FreeRTOS/FreeRTOS-Kernel.git denied to xxx.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
PS D:\FreeRTOS-Kernel>

那么關(guān)于push命令的舉例,我們會(huì)利用作者的私人倉庫中進(jìn)行說明,?在powershell中輸入

git status
git add .
git commit -m "自己想要輸入的信息"
git push origin HEAD

運(yùn)行結(jié)果如

PS D:\mqtt\python_mqtt> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   mqtt_device_ec800_usb.xml

no changes added to commit (use "git add" and/or "git commit -a")
PS D:\mqtt\python_mqtt> git add .
PS D:\mqtt\python_mqtt> git commit -m "fix config of device ec800"
[master bd75bba] fix config of device ec800
 1 file changed, 1 insertion(+), 1 deletion(-)
PS D:\mqtt\python_mqtt> git push origin HEAD
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 299 bytes | 299.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:xxx/mqtt_uart.git
   3784172..bd75bba  HEAD -> master
PS D:\mqtt\python_mqtt>

3.7 pull

git pull [<options>] [<repository> [<refspec>…?]]

官網(wǎng)原文:

Incorporates changes from a remote repository into the current branch. If the current branch is behind the remote, then by default it will fast-forward the current branch to match the remote. If the current branch and the remote have diverged, the user needs to specify how to reconcile the divergent branches with --rebase or --no-rebase (or the corresponding configuration option in pull.rebase).

中文翻譯:

將遠(yuǎn)程倉庫的更改合并到當(dāng)前分支。如果當(dāng)前分支落后于遠(yuǎn)程分支,則默認(rèn)情況下會(huì)快進(jìn)當(dāng)前分支以與遠(yuǎn)程分支匹配。如果當(dāng)前分支和遠(yuǎn)程分支發(fā)生了分歧,用戶需要使用--rebase或--no-rebase(或相應(yīng)的配置選項(xiàng)pull.rebase)來指定如何協(xié)調(diào)這些分歧的分支。

例程說明:pull的用途其實(shí)就是把遠(yuǎn)程倉庫端的代碼同步到本地。

?

在powershell中輸入如下指令

git branch | grep develop
git pull
git log

運(yùn)行結(jié)果

PS D:\jenkins_build\rh850> git branch | grep develop
* develop/mcu1.00_dev
PS D:\jenkins_build\rh850> git pull
remote: Counting objects: 607, done
remote: Finding sources: 100% (17/17)
remote: Total 17 (delta 12), reused 17 (delta 12)
Unpacking objects: 100% (17/17), 2.23 KiB | 14.00 KiB/s, done.
From ssh://172.30.10.205:29418/rh850
   67b6cee..08d5c1b  mcu_main_branch_xxx  -> origin/mcu_main_branch_xxx
 * [new branch]      xxx/mcu1.00_dev1 -> origin/xxx/mcu1.00_dev1
Already up to date.
PS D:\jenkins_build\rh850> git log
commit eab1795ca7a68c051a42c1fdd70555b373469df2 (HEAD -> develop/mcu1.00_dev, origin/xxx/mcu1.00_dev1, origin/develop/mcu1.00_dev)
Author: xxx <xxx@xxx.cn>
Date:   Sat Mar 30 17:22:59 2024 +0800

    add com timeout cfg

commit 1a3d1536c83a908e2b7ed29a520a6da2cb522f0a
Author: xxx <xxx@xxx.cn>
Date:   Sat Mar 30 16:56:38 2024 +0800

    Squashed commit of the following:

    commit 715dd547850f45de50860b7317e92f8aa4596e97
    Author: xxx <xxx@xxx.cn>
    Date:   Tue Mar 19 20:32:16 2024 +0800

        add can timeout diag

commit 3ea9f451300ae09555672654fdda140ce980229d
Author: xxx <xxx@xxx.cn>
Date:   Sat Mar 30 16:42:48 2024 +0800

    Squashed commit of the following:

    commit b057bfc2bc31910a940a3b14020c3fde431d28bf
    Author: xxx <xxx@xxx.cn>
    Date:   Fri Mar 29 20:15:24 2024 +0800

        update spi Tx Transmit

4. 結(jié)語

本文旨在介紹git使用中的最基本的命令,輔以作者自己的操作例程,希望能對大家學(xué)習(xí)git有所幫助,后面作者將會(huì)繼續(xù)更新git的各種高級用法,敬請期待。文章來源地址http://www.zghlxwxcb.cn/news/detail-846643.html

到了這里,關(guān)于Git使用教程:輕松掌握版本控制利器,提升開發(fā)效率!-(1)git的基本命令講解的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【掌握版本控制:Git 入門與實(shí)踐指南】遠(yuǎn)程操作|標(biāo)簽管理

    【掌握版本控制:Git 入門與實(shí)踐指南】遠(yuǎn)程操作|標(biāo)簽管理

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??慕斯主頁 : 修仙—?jiǎng)e有洞天 ?? ????????????????????????????????????????? ??? 今日夜電波: 泥中に咲く—ウォルピスカーター ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

    2024年03月17日
    瀏覽(64)
  • 【掌握版本控制:Git 入門與實(shí)踐指南】配置詳解|理解本地倉庫結(jié)構(gòu)

    【掌握版本控制:Git 入門與實(shí)踐指南】配置詳解|理解本地倉庫結(jié)構(gòu)

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??慕斯主頁 : 修仙—?jiǎng)e有洞天 ?? ????????????????????????????????????????? ??? 今日夜電波:泥中に咲く—ウォルピスカーター ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

    2024年03月13日
    瀏覽(27)
  • 2023 最新 Git 分布式版本控制系統(tǒng)介紹和下載安裝使用教程

    2023 最新 Git 分布式版本控制系統(tǒng)介紹和下載安裝使用教程

    Git 是一個(gè)開源的分布式版本控制系統(tǒng),用于敏捷高效地處理任何或大或小的項(xiàng)目。 集中式和分布式的區(qū)別? 最常見的集中式版本控制系統(tǒng)是SVN,版本庫是集中放在中央處理器中的,而干活的時(shí)候,用的都是自己電腦,所以首先要從中央服務(wù)器那里得到最新的版本,然后開始

    2024年02月09日
    瀏覽(26)
  • 掌握J(rèn)DK21全新結(jié)構(gòu)化并發(fā)編程,輕松提升開發(fā)效率!

    掌握J(rèn)DK21全新結(jié)構(gòu)化并發(fā)編程,輕松提升開發(fā)效率!

    通過引入結(jié)構(gòu)化并發(fā)編程的API,簡化并發(fā)編程。結(jié)構(gòu)化并發(fā)將在不同線程中運(yùn)行的相關(guān)任務(wù)組視為單個(gè)工作單元,從而簡化錯(cuò)誤處理和取消操作,提高可靠性,并增強(qiáng)可觀察性。這是一個(gè)預(yù)覽版的API。 結(jié)構(gòu)化并發(fā)是由JEP 428提出的,并在JDK 19中作為孵化API發(fā)布。它在JDK 20中被

    2024年02月12日
    瀏覽(21)
  • 【Git 入門教程】第四節(jié)、Git沖突:如何解決版本控制的矛盾

    【Git 入門教程】第四節(jié)、Git沖突:如何解決版本控制的矛盾

    Git是目前最流行的版本控制系統(tǒng)之一,它為團(tuán)隊(duì)協(xié)作開發(fā)提供了方便和高效的方式。然而,在多人同時(shí)修改同一個(gè)文件時(shí),可能會(huì)出現(xiàn)代碼 沖突(conflict) ,導(dǎo)致代碼無法正確合并。那么,如何解決Git沖突呢? 在多分支并行處理時(shí),每一個(gè)分支可能是基于不同版本的主干分

    2024年02月05日
    瀏覽(19)
  • Node Version Manager(nvm):輕松管理 Node.js 版本的利器

    Node Version Manager(nvm):輕松管理 Node.js 版本的利器

    Node.js 是現(xiàn)代 Web 開發(fā)中不可或缺的一部分,然而,隨著時(shí)間的推移,Node.js 的不斷更新和發(fā)展,我們往往需要在同一臺(tái)機(jī)器上安裝和管理多個(gè) Node.js 版本,以適應(yīng)不同項(xiàng)目的需求。而在這個(gè)問題上, Node Version Manager(nvm) 成為了解決方案。本文將介紹如何安裝和使用 nvm,讓

    2024年04月28日
    瀏覽(102)
  • pynput:用Python輕松掌握鼠標(biāo)和鍵盤的控制

    pynput:用Python輕松掌握鼠標(biāo)和鍵盤的控制

    引言 控制鼠標(biāo)和鍵盤是自動(dòng)化任務(wù)中的常見需求。在Python中,pynput庫是一種強(qiáng)大的工具,可以幫助我們實(shí)現(xiàn)這些操作。本文將詳細(xì)介紹pynput庫的使用方法,并提供一些示例幫助讀者快速上手。 1. 安裝pynput庫 首先,我們需要安裝pynput庫。可以使用pip命令來進(jìn)行安裝: 2. 控制鼠

    2024年02月04日
    瀏覽(26)
  • 版本控制 Git工具的使用

    版本控制 Git工具的使用

    版本控制(Revision control)是一種在開發(fā)的過程中用于管理我們對文件、目錄或工程等內(nèi)容的修改歷史,方便查看更改歷史記錄,備份以便恢復(fù)以前的版本的軟件工程技術(shù)。簡單來說就是用于管理多人協(xié)同開發(fā)項(xiàng)目的技術(shù)。 沒有進(jìn)行版本控制本身缺乏正確的流程管理,在軟件

    2024年02月10日
    瀏覽(28)
  • 超詳細(xì)Git版本控制及Git的使用

    超詳細(xì)Git版本控制及Git的使用

    目錄 1.Git文件的三種狀態(tài)與工作模式 1.1文件的三種狀態(tài) 1.2Git項(xiàng)目的三個(gè)工作區(qū)域 1.3基本git工作流程 2.Git的使用 2.1Git使用SSH鏈接下載源碼 2.2創(chuàng)建版本庫并提交文件 2.2.1編寫一個(gè)文本文件并將其提交到git倉庫 2.2.2將項(xiàng)目提交到本地倉庫 2.2.3提交文件到本地版本庫 2.3文件的修改

    2024年01月20日
    瀏覽(34)
  • 版本控制工具 - git的安裝與使用

    版本控制工具 - git的安裝與使用

    ??Git 是一個(gè)免費(fèi)和開源 的分布式版本控制系統(tǒng),旨在以速度和效率處理從小型到大型項(xiàng)目的所有內(nèi)容。Git易于學(xué)習(xí) 占用空間小,性能快如閃電. 它優(yōu)于 SCM 工具,如 Subversion, CVS, Perforce, 和 ClearCase 具有 廉價(jià)的本地分支, 方便的暫存區(qū)域和多個(gè)工作流等功能。 git記錄的是什

    2024年02月15日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包