推送到 master 后文件未显示在 github
file does not show up on github after pushing to master
我正在尝试从 cli 更新 github 上的文件,但一无所获。
我的电脑ps:
$ git add myfile.txt
$ git commit -m 'update message'
done. all 2 files are hidden.
[48a989d 8762548] update message
3 files changed, 2 insertions(+), 2 deletions(-)
create mode 100644 dir1/secrets.yaml.secret
create mode 100644 dir2/passwds.secret
$ git push origin master
Everything up-to-date
但是当我在 github 上打开 repo 时,myfile.txt 没有出现。
ps,如你所见,我使用的是git-secret。应该不会影响这个问题,但我提到它 jic。
这是了解发生了什么的关键:
[48a989d 8762548] scenes
对于每次提交,Git 打印一些消息:
$ git commit -m bar
[master 04ce966] bar
1 file changed, 1 insertion(+), 1 deletion(-)
第一行在方括号中包含您当前的分支名称——在本例中,我的分支名称是 master
——以及新提交的哈希 ID,缩写为相当短的内容,在本例中为 04ce966
.
第二行总结了现有文件、新文件和已删除文件的更改内容,任何其他行都会为您提供有关其他可能更改内容的更多信息,特别是新的 and/or 已删除文件。
您的 Git 打印:
48a989d
作为方括号中的第一个单词。这意味着您在 名为 48a989d
的分支上。这不是一个很好的好分支名称——它看起来很像一个提交哈希——但它是一个有效分支名称,就像cafedad
或 feedbed
或 cabbabe
都是有效的分支名称和可能有效的缩写提交哈希。因此,您提交了这些文件,在分支 48a989d
中创建了一个新提交,然后使用未更改的名称 master
推送。
签出master
,将文件放在那里,提交,推送成功。你现在可以 运行 git branch
看到这个奇怪的 48a989d
分支,或者只是 git branch -D 48a989d
强行删除它,如果你确定它没有任何价值。
编辑:我建议使用 git branch
查看它,然后 运行ning git branch -m 48a989d <em>some-better -name</em>
将其名称更改为更明显的名称并使用它,如果您想使用它的话。
根据下面的 eftshift0 评论,我尝试了
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
myfile.txt
dir1/secrets.yaml.secret
dir2/passwds.secret
Please commit your changes or stash them before you switch branches.
Aborting
我认为这可能有所帮助。将在本地备份我的 repo 并尝试隐藏更改
... 5 分钟后...
$ git stash
$ git checkout master
$ cp ~/backup/myfile.txt .
$ git add .
$ git commit -m 'update message'
$ git push origin master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 987 bytes | 987.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:marcwagner/install_scripts.git
2a75b58..92bf3de master -> master
谢谢!
只需将您在 Github 上查看的分支从 main 更改为 master,您就会看到您的文件。
Changing branches
我正在尝试从 cli 更新 github 上的文件,但一无所获。
我的电脑ps:
$ git add myfile.txt
$ git commit -m 'update message'
done. all 2 files are hidden.
[48a989d 8762548] update message
3 files changed, 2 insertions(+), 2 deletions(-)
create mode 100644 dir1/secrets.yaml.secret
create mode 100644 dir2/passwds.secret
$ git push origin master
Everything up-to-date
但是当我在 github 上打开 repo 时,myfile.txt 没有出现。 ps,如你所见,我使用的是git-secret。应该不会影响这个问题,但我提到它 jic。
这是了解发生了什么的关键:
[48a989d 8762548] scenes
对于每次提交,Git 打印一些消息:
$ git commit -m bar
[master 04ce966] bar
1 file changed, 1 insertion(+), 1 deletion(-)
第一行在方括号中包含您当前的分支名称——在本例中,我的分支名称是 master
——以及新提交的哈希 ID,缩写为相当短的内容,在本例中为 04ce966
.
第二行总结了现有文件、新文件和已删除文件的更改内容,任何其他行都会为您提供有关其他可能更改内容的更多信息,特别是新的 and/or 已删除文件。
您的 Git 打印:
48a989d
作为方括号中的第一个单词。这意味着您在 名为 48a989d
的分支上。这不是一个很好的好分支名称——它看起来很像一个提交哈希——但它是一个有效分支名称,就像cafedad
或 feedbed
或 cabbabe
都是有效的分支名称和可能有效的缩写提交哈希。因此,您提交了这些文件,在分支 48a989d
中创建了一个新提交,然后使用未更改的名称 master
推送。
签出master
,将文件放在那里,提交,推送成功。你现在可以 运行 git branch
看到这个奇怪的 48a989d
分支,或者只是 git branch -D 48a989d
强行删除它,如果你确定它没有任何价值。
编辑:我建议使用 git branch
查看它,然后 运行ning git branch -m 48a989d <em>some-better -name</em>
将其名称更改为更明显的名称并使用它,如果您想使用它的话。
根据下面的 eftshift0 评论,我尝试了
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
myfile.txt
dir1/secrets.yaml.secret
dir2/passwds.secret
Please commit your changes or stash them before you switch branches.
Aborting
我认为这可能有所帮助。将在本地备份我的 repo 并尝试隐藏更改
... 5 分钟后...
$ git stash
$ git checkout master
$ cp ~/backup/myfile.txt .
$ git add .
$ git commit -m 'update message'
$ git push origin master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 987 bytes | 987.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:marcwagner/install_scripts.git
2a75b58..92bf3de master -> master
谢谢!
只需将您在 Github 上查看的分支从 main 更改为 master,您就会看到您的文件。
Changing branches