Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_remotes [2018/06/07 12:19] – [ADD] rpjday | git_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 ===== | ||
| - | |||
| - | < | ||
| - | $ git ls-remote [< | ||
| - | $ git remote show < | ||
| - | $ git remote prune | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | $ git fetch --all; git branch -vv | ||
| - | $ gut push origin thisbranch: | ||
| - | $ git push origin --delete < | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | $ git checkout --track origin/ | ||
| - | $ git checkout -b sf origin/ | ||
| - | $ git branch [-u|--set-upstream-to] origin/ | ||
| - | </ | ||
| - | |||
| - | Shorthand if you're on the '' | ||
| - | |||
| - | < | ||
| - | $ git merge origin/ | ||
| - | $ git merge @{upstream} | ||
| - | $ git merge @{u} | ||
| - | </ | ||
| - | ===== Example with the Linux kernel ===== | ||
| - | |||
| - | To start, consider the status of the //local tracking branch// '' | ||
| - | |||
| - | < | ||
| - | $ git status | ||
| - | On branch master | ||
| - | Your branch is up-to-date with ' | ||
| - | |||
| - | nothing to commit, working tree clean | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | 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// '' | ||
| - | |||
| - | < | ||
| - | $ 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:// | ||
| - | | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | Note what '' | ||
| - | |||
| - | < | ||
| - | $ git status | ||
| - | On branch master | ||
| - | Your branch is behind ' | ||
| - | (use "git pull" to update your local branch) | ||
| - | |||
| - | nothing to commit, working tree clean | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | You can check out a remote tracking branch, but you shouldn' | ||
| - | |||
| - | < | ||
| - | $ git checkout origin/ | ||
| - | Note: checking out ' | ||
| - | |||
| - | You are in ' | ||
| - | 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 < | ||
| - | |||
| - | HEAD is now at 61f14c015f5b... Merge tag ' | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | ===== Adding the " | ||
| - | |||
| - | Based on the web page [[https:// | ||
| - | |||
| - | < | ||
| - | $ git remote | ||
| - | origin | ||
| - | $ git remote -v | ||
| - | origin https:// | ||
| - | origin https:// | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | Add the remote with whatever meaningful name works for you: | ||
| - | |||
| - | < | ||
| - | $ git remote add ln \ | ||
| - | > https:// | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | Verify you have a second remote: | ||
| - | |||
| - | < | ||
| - | $ git remote -v | ||
| - | ln https:// | ||
| - | ln https:// | ||
| - | origin https:// | ||
| - | origin https:// | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | Now fetch the new content from the new remote: | ||
| - | |||
| - | < | ||
| - | $ git fetch [--tags] ln | ||
| - | remote: Counting objects: 109900, done. | ||
| - | remote: Compressing objects: 100% (19971/ | ||
| - | remote: Total 109900 (delta 95864), reused 103738 (delta 89778) | ||
| - | Receiving objects: 100% (109900/ | ||
| - | Resolving deltas: 100% (95864/ | ||
| - | From https:// | ||
| - | * [new branch] | ||
| - | * [new branch] | ||
| - | * [new branch] | ||
| - | * [new branch] | ||
| - | * [new tag] | ||
| - | * [new tag] | ||
| - | * [new tag] | ||
| - | * [new tag] | ||
| - | * [new tag] | ||
| - | ... big snip ... | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | List all remote branches in the object store: | ||
| - | |||
| - | < | ||
| - | $ git branch -r | ||
| - | ln/akpm | ||
| - | ln/ | ||
| - | ln/master | ||
| - | ln/stable | ||
| - | origin/HEAD -> origin/ | ||
| - | origin/ | ||
| - | $ | ||
| - | </ | ||
| - | |||
| - | Start tracking: | ||
| - | |||
| - | < | ||
| - | $ git checkout -b lnmaster --track ln/master | ||
| - | </ | ||
| - | |||