Clone a repository, make a change and push it
Description: Clone the repository server.git into a folder my-work, add a file todo.txt, commit it and push it to the remote.
Hint:
- A clone already has the remote
origin, so a plaingit pushis enough.
Solution
Terminal output
$ git clone server.git my-work
Cloning into 'my-work'…
done.
$ cd my-work
$ echo "buy milk" > todo.txt
$ git add todo.txt
$ git commit -m "Add todo list"
[main 9eaf666] Add todo list
1 file changed, 1 insertion(+)
create mode 100644 todo.txt
$ git push
To /home/robin/server.git
4f5618b..9eaf666 main -> main
How it works
- We used a local folder as the server. A GitHub URL works in the same way.
- The last line shows that
mainwas pushed to the remotemain.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |