如何用命令行(Linux系统),将本地脚本上传github - Yuan-SW-F(abysw)

时间:2024-01-27 18:39:45

如何用命令行(Linux系统),将本地脚本上传github

1. 申请github账号,在账号中新建仓库:

 

 

 

 创建。

 

 

 

 很简单,就是在本地需要上传的文件夹,运行上述命令:

 

 然后刷新github页面:

 

 那么新增文件怎么上传呢?

 

 然后刷新:

 

 很简单,将所有命令复制如下:

$ mkdir test
[root@Yuan-SW-F 2020-11-18 10:42 /Yuan/Ypip2.0]
$ cd test
[root@Yuan-SW-F 2020-11-18 10:42 /Yuan/Ypip2.0/test]
$ git init
Initialized empty Git repository in /Yuan/Ypip2.0/test/.git/
[root@Yuan-SW-F 2020-11-18 10:42 /Yuan/Ypip2.0/test]
$ echo "this is a test file" > readme.md
[root@Yuan-SW-F 2020-11-18 10:42 /Yuan/Ypip2.0/test]
$ git add readme.md
[root@Yuan-SW-F 2020-11-18 10:42 /Yuan/Ypip2.0/test]
$ git commit -m "the first one"
[master (root-commit) 08f79d1] the first one
1 file changed, 1 insertion(+)
create mode 100644 readme.md
[root@Yuan-SW-F 2020-11-18 10:43 /Yuan/Ypip2.0/test]
$ git branch -M main
[root@Yuan-SW-F 2020-11-18 10:43 /Yuan/Ypip2.0/test]
$ git remote add origin https://github.com/Yuan-SW-F/test.git
[root@Yuan-SW-F 2020-11-18 10:44 /Yuan/Ypip2.0/test]
$ git push -u origin main
Username for \'https://github.com\': Yuan-SW-F
Password for \'https://Yuan-SW-F@github.com\':
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/Yuan-SW-F/test.git
* [new branch] main -> main
Branch main set up to track remote branch main from origin.
[root@Yuan-SW-F 2020-11-18 10:44 /Yuan/Ypip2.0/test]
$ echo "test file2" > test_file2.txt
[root@Yuan-SW-F 2020-11-18 10:47 /Yuan/Ypip2.0/test]
$ git add test_file2.txt
[root@Yuan-SW-F 2020-11-18 10:47 /Yuan/Ypip2.0/test]
$ git commit -m "new file"
[main 5b852c3] new file
1 file changed, 1 insertion(+)
create mode 100644 test_file2.txt
[root@Yuan-SW-F 2020-11-18 10:47 /Yuan/Ypip2.0/test]
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from \'matching\' to \'simple\'. To squelch this message
and maintain the traditional behavior, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to \'matching\', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative \'simple\'
behavior, which only pushes the current branch to the corresponding
remote branch that \'git pull\' uses to update the current branch.

See \'git help config\' and search for \'push.default\' for further information.
(the \'simple\' mode was introduced in Git 1.7.11. Use the similar mode
\'current\' instead of \'simple\' if you sometimes use older versions of Git)

Username for \'https://github.com\': Yuan-SW-F
Password for \'https://Yuan-SW-F@github.com\':
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 290 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/Yuan-SW-F/test.git
08f79d1..5b852c3 main -> main

 

很是简单,

以上,

abyss SW F