1

This question has probably been asked 100s of times on the internet.

I made changes to a Gemfile and _config.yml. I git add -A, git commit -m, git push. Go online to check github and the files I updated have not changed.

Read through online forums for hours. I have updated post-receive, checked the .gitignore file. Not sure what I'm doing wrong. The most frustrating part is that git seems to be pretty straightforward and I'm probably missing something very simple.

After trying many different things, git status returns the following:

HEAD detached at origin/master
nothing to commit, working tree clean

Previously, I was mostly getting the "everything up-to-date message", no matter what I did.

Nahuatl_C137
  • 132
  • 1
  • 13
  • https://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin – parlad Dec 08 '18 at 18:27

1 Answers1

2

HEAD detached means you did not push your (detached) HEAD branch to the master branch.

You need to restore said HEAD and merge it to master before pushing once again.

git branch my-temporary-work
git checkout master
git merge my-temporary-work
git push

Note: that pushes to the remote master branch.
But id the remote repo is set to show a different branch, that means you would not see your commits right away: you would need to switch back to the master branch first (through the GitHub web UI).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • After restoring HEAD by git checkout master, and git push, I get the message "Everything up-to-date". Since way earlier, I had updated a Gemfile and created a test blog post which are not in git yet. – Nahuatl_C137 Dec 08 '18 at 22:30
  • @Nahuatl_C137 Do you see what you have updated pushed on the remote side? What git status is showing you now? – VonC Dec 08 '18 at 22:32
  • $ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean – Nahuatl_C137 Dec 08 '18 at 22:34
  • @Nahuatl_C137 Then whatever you have locally on master should be reflected on the remote repo. – VonC Dec 08 '18 at 22:34
  • https://imgur.com/a/YF2WSgQ - you can see that there there are 2 new lines, but on git, it still shows the original file that was in there. – Nahuatl_C137 Dec 08 '18 at 22:38
  • @Nahuatl_C137 What does `git config --check-ignore -v -- Gemfile` and `git config --check-ignore -v -- _config.yml.` return? If the output is empty, then they are *not* ignored and should be added, committed and pushed without any issue. – VonC Dec 08 '18 at 22:40
  • After running, I get error "unknown option `check-ignore`. Trying to troubleshoot. – Nahuatl_C137 Dec 08 '18 at 22:50
  • `git status --ignored` worked for me. According to the below SO link, I don't have any untracked files since I only get a normal status output. https://stackoverflow.com/questions/18596867/what-is-the-git-command-to-list-ignored-files/18596993 – Nahuatl_C137 Dec 08 '18 at 23:00
  • @Nahuatl_C137 What version of Git are you using? Make sure to upgrade to 2.19.2 – VonC Dec 08 '18 at 23:09
  • Upgraded. Still can't run `git config --check-ignore -v -- Gemfile`. Error is "unknown option check-ignore". I also get a list of options for git config. – Nahuatl_C137 Dec 08 '18 at 23:14
  • @Nahuatl_C137 Sorry, the command was `git check-ignore -v -- aFile` – VonC Dec 08 '18 at 23:15
  • Running `git check-ignore -v -- Gemfie` or _config.yml produces no results. – Nahuatl_C137 Dec 08 '18 at 23:25
  • @Nahuatl_C137 if you add a modification to those files, are they marked as "to be added" on a subsequent git status? – VonC Dec 08 '18 at 23:33
  • updated _config.yml; `git stage _config.yml`; `git commit -m "update to config"` - produces output [master 066df80] update to config 1 file changed, 1 insertion(+), 1 deletion(-); `git push` runs ok as well - to https://github.com/username/repo.git master -> master – Nahuatl_C137 Dec 08 '18 at 23:41
  • @Nahuatl_C137 git stage??? it should be git add, not git stage. Do you see what you have committed on the remote side? If not, try again (modification, and this time git add) – VonC Dec 08 '18 at 23:44
  • Made a new update. `git add _config.yml`, `git commit -m "..."`, `git push` all successful but zero changes to the remote file. – Nahuatl_C137 Dec 08 '18 at 23:49
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184943/discussion-between-vonc-and-nahuatl-c137). – VonC Dec 08 '18 at 23:51