Search code examples
gitgithubpush

file does not show up on github after pushing to master


I'm trying to update files on github from the cli, but getting nowhere.

my steps:

$ 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

but when I open the repo on github, myfile.txt does not show up. ps, as you can see, I am using git-secret. should not affect this problem, but i am mentioning it jic.


Solution

  • This is the key to knowing what was happening:

    [48a989d 8762548] scenes
    

    For each commit, Git prints a few messages:

    $ git commit -m bar
    [master 04ce966] bar
     1 file changed, 1 insertion(+), 1 deletion(-)
    

    The first line has, in square brackets, your current branch name—in this case, mine was master—and the new commit's hash ID, abbreviated to something reasonably short, in this case 04ce966.

    The second line has a summary of what changed in existing, new, and deleted files, and any additional lines give you more information about what else might have changed, specifically new and/or removed files.

    Your Git printed:

    48a989d
    

    as the first word in the square brackets. That means you were on a branch named 48a989d. This is not a very good branch name—it looks a lot like a commit hash—but it is a valid branch name, just as cafedad or feedbed or cabbabe are all both valid branch names and potentially valid abbreviated commit hashes as well. So you committed these files, creating a new commit in branch 48a989d, then pushed using the name master, which had not changed.

    Checking out master, putting the files in there, committing, and pushing succeeded. You can now run git branch to see this odd 48a989d branch, or just git branch -D 48a989d to forcibly delete it if you are sure that there is nothing of value in it.

    Edit: I'd recommend using git branch to see it, then running git branch -m 48a989d some-better-name to change its name to something more obvious and to work with it, if you want to work with it.