Add answer to remote-commands.md

This commit is contained in:
sosokker 2023-08-21 20:20:00 +07:00
parent 50fa418a42
commit d400408a3a

View File

@ -1,16 +1,12 @@
## Commands for Remotes
> TODO Write your answers and then remove **all** the TODO comments
```
1. List all your remote repositories and show their URLs:
```
Todo write the git command for this
git remote -v
```
2. View details about a remote repo named `origin`, including all the remote branches and local tracking branches for `origin`:
```
Todo write the git command for this
git remote show origin
```
3. (Pushing a new branch) You commit some files to the `dev-foo` branch and try to "push" them to Github, but it fails as shown here:
@ -21,21 +17,23 @@
fatal: The current branch dev-foo has no upstream branch.
```
Explain this error.
> TODO Since you are writing an explanation (not shell commands), write your answer in lines beginning with `>` like this one. The text will be formatted and may include Markdown.
> This error occurs because the local branch `dev-foo` does not have an associated remote tracking branch. We can fix this by using the command `git push -u origin dev-foo` to establish a tracking relationship.
4. The command to push `dev-foo` to `origin` as a **new remote branch** on `origin` is:
```
git push origin dev-foo
```
5. (Create a local tracking branch for a remote branch) The remote repository (`origin`) has a branch named `e2e-test` that you don't have in your local repository.
The command to create a new local branch as a copy of the remote `e2e-test` branch that **tracks** the remote branch is:
```
Todo There are many commands that will do this. You may write one or more than one.
git checkout -b e2e-test origin/e2e-test
```
6. The command to change the URL of the remote "origin" to a new URL, such as `https://hostname/newuser/new-repo-name`, is:
```
TODO your answer
git remote set-url origin https://hostname/newuser/new-repo-name
```
This situation occurs when:
- you change the name of a repo on Github
@ -45,7 +43,7 @@
8. To create a *second* remote repository for your local repo, the command to add a remote named "bitbucket" with the URL "https://bitbucket.org/your-username/git-commands" is:
```
todo your answer
git remote add bitbucket https://bitbucket.org/your-username/git-commands
```
- Note: you must **create** an empty repo on Bitbucket. This command just adds it as a remote, it won't create the remote repo.