git_remotes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_remotes [2018/06/07 12:12] – [ADD] rpjdaygit_remotes [2019/04/04 03:23] (current) – removed rpjday
Line 1: Line 1:
-===== Overview ===== 
- 
-Discussion and demonstration of remote tracking branches and adding remotes. 
- 
-===== ADD ===== 
- 
-<code> 
-$ git ls-remote [<remote>] 
-$ git remote show <remote> 
-$ git remote prune 
-</code> 
- 
-<code> 
-$ git fetch --all; git branch -vv 
-$ gut push origin thisbranch:thatbranch 
-$ git push origin --delete <branchname> 
-</code> 
- 
-<code> 
-$ git checkout --track origin/serverfix 
-</code> 
-===== Example with the Linux kernel ===== 
- 
-To start, consider the status of the //local tracking branch// ''master'': 
- 
-<code> 
-$ git status 
-On branch master 
-Your branch is up-to-date with 'origin/master'. 
- 
-nothing to commit, working tree clean 
-$ 
-</code> 
- 
-If we want to fetch new content but not merge it with our local tracking branch, we can just fetch the new content to the //remote tracking branch// ''origin/master'': 
- 
-<code> 
-$ git fetch 
-remote: Counting objects: 85, done. 
-remote: Total 85 (delta 70), reused 70 (delta 70), pack-reused 15 
-Unpacking objects: 100% (85/85), done. 
-From https://github.com/torvalds/linux 
-   7928b2cbe55b..61f14c015f5b  master     -> origin/master 
-$ 
-</code> 
- 
-Note what ''git status'' tells us now: 
- 
-<code> 
-$ git status 
-On branch master 
-Your branch is behind 'origin/master' by 13 commits, and can be fast-forwarded. 
-  (use "git pull" to update your local branch) 
- 
-nothing to commit, working tree clean 
-$ 
-</code> 
- 
-You can check out a remote tracking branch, but you shouldn't try to make any changes to it %%--%% that's not what it's for: 
- 
-<code> 
-$ git checkout origin/master 
-Note: checking out 'origin/master'. 
- 
-You are in 'detached HEAD' state. You can look around, make experimental 
-changes and commit them, and you can discard any commits you make in this 
-state without impacting any branches by performing another checkout. 
- 
-If you want to create a new branch to retain commits you create, you may 
-do so (now or later) by using -b with the checkout command again. Example: 
- 
-  git checkout -b <new-branch-name> 
- 
-HEAD is now at 61f14c015f5b... Merge tag 'mips_4.16_2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips 
-$ 
-</code> 
- 
-===== Adding the "linux-next" remote ===== 
- 
-Based on the web page [[https://www.kernel.org/doc/man-pages/linux-next.html|here]], first verify that there is only one remote: 
- 
-<code> 
-$ git remote 
-origin 
-$ git remote -v 
-origin https://github.com/torvalds/linux.git (fetch) 
-origin https://github.com/torvalds/linux.git (push) 
- 
-</code> 
- 
-Add the remote with whatever meaningful name works for you: 
- 
-<code> 
-$ git remote add ln \ 
-> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
-$ 
-</code> 
- 
-Verify you have a second remote: 
- 
-<code> 
-$ git remote -v 
-ln https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (fetch) 
-ln https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (push) 
-origin https://github.com/torvalds/linux.git (fetch) 
-origin https://github.com/torvalds/linux.git (push) 
-$ 
-</code> 
- 
-Now fetch the new content from the new remote: 
- 
-<code> 
-$ git fetch [--tags] ln 
-remote: Counting objects: 109900, done. 
-remote: Compressing objects: 100% (19971/19971), done. 
-remote: Total 109900 (delta 95864), reused 103738 (delta 89778) 
-Receiving objects: 100% (109900/109900), 17.48 MiB | 1.14 MiB/s, done. 
-Resolving deltas: 100% (95864/95864), completed with 4062 local objects. 
-From https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next 
- * [new branch]                akpm          -> ln/akpm 
- * [new branch]                akpm-base     -> ln/akpm-base 
- * [new branch]                master        -> ln/master 
- * [new branch]                stable        -> ln/stable 
- * [new tag]                   next-20171115 -> next-20171115 
- * [new tag]                   next-20171116 -> next-20171116 
- * [new tag]                   next-20171117 -> next-20171117 
- * [new tag]                   next-20171120 -> next-20171120 
- * [new tag]                   next-20171121 -> next-20171121 
-  ... big snip ... 
-$ 
-</code> 
- 
-List all remote branches in the object store: 
- 
-<code> 
-$ git branch -r 
-  ln/akpm 
-  ln/akpm-base 
-  ln/master 
-  ln/stable 
-  origin/HEAD -> origin/master 
-  origin/master 
-$ 
-</code> 
- 
-Start tracking: 
- 
-<code> 
-$ git checkout -b lnmaster --track ln/master 
-</code> 
- 
  
  • git_remotes.1528373532.txt.gz
  • Last modified: 2018/06/07 12:12
  • by rpjday