Day 8
Collaborating with Remotes
Commands in Play
- git remote
- git ls-remote
- git remote -v show
Show me the remote URL using switches on git remote
on CLI.- fetch -> For the purposes of download (receive) files from a remote, you can replace this command with pull.
- push -> Uploads (sends) files to the remote.
- git clone -> REM. This command creates remote-tracking branches in the new repository. There are branches in the original repository, and these remote-tracking branches serve as bookmarks back to them.
- git branch —all
- git remote rename [origin] [new-remote-name] -> Rename those bookmarks; only affecting your local branch!
- git remote add [remote-name] [../relative-branch location]
- gh repo clone [github URL] [target-dir] -> Done by me, for me, as I have the gh go package installed.
12.1.3 Adding a remote
You can even add a remote. That’s right. Even after you make a clone, you can add another remote, which represents another repository that you want to track. If you collaborate on a repository where contributors are actively developing on their own repositories, it may be useful to add their repositories, in addition to the remote that was created when you first did the clone.
TDB: A cool representation of this in comic form, à la what Julia Evans (@b0rk) does so wonderfully.
![Add a branch to the repo at dir math.bob and it is not seen to local dir math.carol.](day8-03.png)
12.4 Lab
In dir math.github, type
git log —oneline —decorate
A:4465c54 (HEAD -> master, origin/master, origin/HEAD) A small update to readme. 6f6af16 Adding printf. 256d402 Adding two numbers. 23d3077 (origin/another_fix_branch) Renaming c and d. 80f5738 Removed a and b. 94abe13 Adding readme.txt ef47d3f (tag: four_files_galore) Adding four empty files. 3847b0b Adding b variable. 2732d6a This is the second commit. e7a974f This is the first commit.
``
What is the SHA1 ID of the remote-tracking branch another_fix_branch?
A: SHA1 ID 23d3077Is there a tag or branch for the SHA1 ID ef47d3f?
A: It’s tag: four_files_galoreAre the SHA1 IDs of math.github the same as math.bob or math.clone? Why not?
A: They are not because the local repos and files where generated by bash script and have no relation to the GitHub based remote (although the contents may otherwise be closely related e.g. four_files_galore is still empty files: a, b, c, and d.)