- Firstly, add key to the workstation following the tutorial of https://www.runoob.com/w3cnote/git-guide.html
- Build a new repository online called “GithubTest”
- cd to the local folder
- In git bash:
-
1git init
-
- In git bash:
-
1git remote add origin git@github.com:xmeng525/GitHubTest.git
-
- Add a new file in the local folder called “readme.md”
- In git bash:
-
1git add readme.md
-
- In git bash:
-
1git commit -m "first commit: Add readme.md"
- will get responce:
-
12345[master (root-commit) c94f00c] first commit: Add readme.md1 file changed, 1 insertion(+)create mode 100644 readme.md
-
-
- The local git repository is constructed by 3 trees:
- The first one is working repository, which contains read files;
- The second one is tmp repository (Index), which stores the changes;
- The third one is head, which points to the last change. Now we have already stored the change to “head”, now we submit it to the working repository.
- In git bash:
-
123$ git push origin masteror$ git push origin HEAD:main
-
123456789Counting objects: 3, done.Writing objects: 100% (3/3), 234 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote:remote: Create a pull request for 'master' on GitHub by visiting:remote: https://github.com/xmeng525/GithubTest/pull/new/masterremote:To git@github.com:xmeng525/GitHubTest.git* [new branch] master -> master
-
-
Now the file “readme.md” is online!