[Software Testing] Use of Git Remote Warehouse (Details)


foreword

View remote warehouse

If you want to view the remote warehouse server you have configured, you can run the git remote command, which will list the name of each remote server you specified;
if it is your own library that has just been cloned, you can see origin, which is started by Git default name;

$ git clone https://github.com/schacon/ticgit
Cloning into 'ticgit'...
remote: Reusing existing pack: 1857, done.
remote: Total 1857 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1857/1857), 374.35 KiB | 268.00 KiB/s, done.
Resolving deltas: 100% (772/772), done.
Checking connectivity... done.
$ cd ticgit
$ git remote
origin

-v option:
will display the URL and name (origin) of Git that needs to read and write the remote warehouse

git remote -v
origin    https://github.com/schacon/ticgit (fetch)
origin    https://github.com/schacon/ticgit (push)

Example:
If there is more than one remote warehouse, this command will list them all
Collaborate with others, warehouses with multiple remote warehouses

$ cd grit
$ git remote -v
bakkdoor  https://github.com/bakkdoor/grit (fetch)
bakkdoor  https://github.com/bakkdoor/grit (push)
cho45     https://github.com/cho45/grit (fetch)
cho45     https://github.com/cho45/grit (push)
defunkt   https://github.com/defunkt/grit (fetch)
defunkt   https://github.com/defunkt/grit (push)
koke      git://github.com/koke/grit.git (fetch)
koke      git://github.com/koke/grit.git (push)
origin    [email protected]:mojombo/grit.git (fetch)
origin    [email protected]:mojombo/grit.git (push)

Add remote warehouse

git remote add <shortname> <url>

Add a new remote Git repository, specifying a name at the same time

polo@B-J5D1MD6R-2312 watermarker % git remote -v
origin    [email protected]:poloyy/watermarker.git (fetch)
origin    [email protected]:poloyy/watermarker.git (push)

polo@B-J5D1MD6R-2312 watermarker % git  remote add test  [email protected]:testyy/waterm
arker.git

polo@B-J5D1MD6R-2312 watermarker % git remote -v
origin    [email protected]:poloyy/watermarker.git (fetch)
origin    [email protected]:poloyy/watermarker.git (push)
test    [email protected]:testyy/watermarker.git (fetch)
test    [email protected]:testyy/watermarker.git (push)

You can use test instead of the entire URL

Git fetch example:
You can run git fetch pb to pull warehouse data

$ git fetch pb
remote: Counting objects: 43, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 43 (delta 10), reused 31 (delta 5)
Unpacking objects: 100% (43/43), done.
From https://github.com/paulboone/ticgit
 * [new branch]      master     -> pb/master
 * [new branch]      ticgit     -> pb/ticgit

Grab and pull from a remote repository

To get data from a remote warehouse, you can execute

git fetch <remote>

This command will access the remote warehouse and pull all the data from it that you don't have yet.
After execution, you will have references to all branches in that remote warehouse, which can be merged or viewed at any time

Key point:
The git clone command clones a warehouse, Git will automatically add it as a remote warehouse and default to "origin" as the name

git fetch origin

This will grab all the new push content in the warehouse;
but it will only download the new content to the local, and will not automatically merge or modify the current content, you need to manually merge the new content into the local content (git pull);

Initial understanding of git pull

By default, the git clone command will automatically set the local master branch to track the master branch of the cloned remote warehouse (or the default branch with other names)

Running git pull will normally fetch data from the server it was originally cloned on and automatically attempt to merge into the branch it is currently on

Push to remote warehouse

grammatical format

git push <remote> <branch>

Push the contents of the master branch to the origin server

git push origin master

remote is origin by default, and branch is master by default, so the equivalent writing is

git push

Important:
If the remote warehouse already has newly pushed content before you push it, then the local needs to pull the latest content and merge it before re-push the local content to the remote warehouse

# 一般的流程
git fetch
git pull
git add .
git commit -m "update"
git push

View a remote repository

git remote show <remote>

You can view more information about remote warehouses

% git  remote show origin
* 远程 origin
  获取地址:[email protected]:poloyy/watermarker.git
  推送地址:[email protected]:poloyy/watermarker.git
  HEAD 分支:master
  远程分支:
    master 已跟踪
  为 'git pull' 配置的本地分支:
    master 与远程 master 合并
  为 'git push' 配置的本地引用:
    master 推送至 master (可快进)

The information that can be obtained
URL and name (origin) of the remote warehouse;
tracking branch information;
currently in the master branch;
executing git pull can pull the master content of the remote warehouse and merge it with the content of the local master branch;
execute git push You can push the content of the local master branch to the master branch of the remote warehouse;

see more information

$ git remote show origin
* remote origin
  URL: https://github.com/my-org/complex-project
  Fetch URL: https://github.com/my-org/complex-project
  Push  URL: https://github.com/my-org/complex-project
  HEAD branch: master
  Remote branches:
    master                           tracked
    dev-branch                       tracked
    markdown-strip                   tracked
    issue-43                         new (next fetch will store in remotes/origin)
    issue-45                         new (next fetch will store in remotes/origin)
    refs/remotes/origin/issue-11     stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    dev-branch merges with remote dev-branch
    master     merges with remote master
  Local refs configured for 'git push':
    dev-branch                     pushes to dev-branch                     (up to date)
    markdown-strip                 pushes to markdown-strip                 (up to date)
    master                         pushes to master                         (up to date)

Contains information from multiple branches

Renaming and removing remote warehouses

grammatical format

git remote rename <old> <new>

example:

$ git remote rename pb paul
$ git remote
origin
paul

At the same time, it will modify the names of all your remote-tracking branches. Those that previously referenced pb/master will now refer to paul/master

Two Ways to Write Removal Warehouse

git remote remove
git remote rm
git remote remove paul
$ git remote
origin

Once a remote warehouse is deleted in this way, all remote tracking branches and configuration information related to this remote warehouse will also be deleted together

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Only by doing your best can you make your dreams no longer far away; only by persisting in struggle can you make success yours; only by pursuing bravely can you make life more exciting. No matter how difficult it is, believe in your own strength and work hard to pursue it, in order to win a brilliant future!

Go forward bravely, not afraid of difficulties; do your best, fearless; step by step, move towards the road to success; as long as you have a dream in your heart, any difficulty will be overcome. Struggle, the future glory belongs to you!

Only with down-to-earth persistence can we break through ourselves and work hard for our dreams. No matter how difficult it is, as long as you have firm belief, every struggle is a valuable experience towards success. Achievements will eventually belong to those who strive through perseverance and perseverance.

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/131661362