1、在github上创建一个项目,然后git clone到本地。
2、将本地的项目放到和这个文件夹中
git add README.md //文件添加到仓库
git add . //不但可以跟单一文件,还可以跟通配符,更可以跟目录。一个点就把当前目录下所有未追踪的文件全部add了
$ git config user.name "myysophia"
$ git config user.email "2324234234234@126.com"
git config –global 参数,有了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然你也可以对某个仓库指定的不同的用户名和邮箱。
公钥就是那个用来加密的数字,这也就是为什么你在本机生成了公钥之后,要上传到github的原因。从github发回来的,用那公钥加密过的数据,可以用你本地的私钥来还原。
有了这个token就不用你每次push输入密码了。
参考:https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
$ git commit -m "init"
[main 761dc09] init
10 files changed, 278 insertions(+)
create mode 100644 master1/Vagrantfile
create mode 100644 master1/install.sh
create mode 100644 master1/reload-k8s-cls.sh
create mode 100644 master1/startk8s.sh
create mode 100644 node/Vagrantfile
create mode 100644 node/install.sh
create mode 100644 node/reload-k8s-cls.sh
create mode 100644 shutdown.sh
create mode 100644 startk8s.sh
git remote add origin1 git@github.com:myysophia/vagrant-init-k8s-cls.git //关联远程仓库
git push -u origin1 master //把本地库的所有内容推送到远程库上
error: src refspec master does not match any
error: failed to push some refs to 'github.com:myysophia/vagrant-init-k8s-cls.git'
git remote -v
origin https://github.com/myysophia/vagrant-init-k8s-cls.git (fetch)
origin https://github.com/myysophia/vagrant-init-k8s-cls.git (push)
origin1 git@github.com:myysophia/vagrant-init-k8s-cls.git (fetch)
origin1 git@github.com:myysophia/vagrant-init-k8s-cls.git (push)
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
stackoverflow最高赞使用这个方法解决了这个问题。第二高赞使用的是git push -f origin master。好像首次push都会有这个问题
$ git pull --rebase origin main
From https://github.com/myysophia/vagrant-init-k8s-cls
* branch main -> FETCH_HEAD
Current branch main is up to date.
$ git push origin main
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 4 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 3.70 KiB | 946.00 KiB/s, done.
Total 14 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), done.
To https://github.com/myysophia/vagrant-init-k8s-cls.git
cf957eb..761dc09 main -> main
https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote
https://morningspace.github.io/tech/git-merge-stories-6/
yeah 上传成功了,快来赞一个吧
https://github.com/myysophia/vagrant-init-k8s-cls
https://zhuanlan.zhihu.com/p/193140870
git init
git remote add origin http://10.50.10.71/wangxu0318/chot-rabbitmq-k8s-chart.git
git add .
git commit -m "chartdemo"
git push -u origin master
执行 git push -u -f origin master
提示需要输入密码,不管是输入gitlab的登录密码还是服务器密码都不行。 看来gitlab 不支持这种验证方式。
这个现在还不会等玩会了再来。
修改项目保护机制。
报错如下:
/home/scripts/etl]$git push
git: /usr/local/greenplum-loaders-4.3.16.1/lib/libz.so.1: no version information available (required by git)
The authenticity of host '10.50.10.71 (10.50.10.71)' can't be established.
RSA key fingerprint is c8:d9:8c:ae:6b:fd:f7:6c:ae:06:17:b5:16:f1:08:a8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.50.10.71' (RSA) to the list of known hosts.
To git@10.50.10.71:wangxu0318/etl-tools.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@10.50.10.71:wangxu0318/etl-tools.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
解决:
git pull --rebase origin master
git pull = git fetch + git merge FETCH_HEAD
git pull --rebase = git fetch + git rebase FETCH_HEAD
什么是git rebase
https://blog.csdn.net/weixin_42310154/article/details/119004977