Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

github-upload : failed to upload

Solved! Go to Solution.

Hello, I just completed the Uploading your project course in the Learning Lab. However, I was able to complete it despite not being able to upload any files to the repository.

 

I am posting this both as a question and as a possible bug -- the bot somehow moved on to the next issue even though I didn't complete the instructions.

 

Here are the instructions for uploading from the exercise:

 

Spoiler
  1. In your command line, navigate to your project directory. Type git init to initialize the directory as a Git repository.
  2. Type git remote add origin https://github.com/[current username]/github-upload.git
  3. Type git add .
  4. Type git commit -m "initializing repository"
  5. Type git push -u origin master to push the files you have locally to the remote on GitHub. (You may be asked to log in.)

At step 5, the output is error: failed to push some refs to [url]

hint: ...the remote contains work you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (eg., git pull ...) before pushing again. See the note about fast-forwards in 'git push --help' for details.

 

The only files in the online repo not in the local folder was the .gitignore (which cannot be created on Windows). After reading the note mentioned in the hint, I tried using --set-upstream origin master --force, but this failed with the error: GH007: Your push would publish a private email address. I do not want to resolve it by setting my email to be public, but I think this error message is incorrect anyway, as there is no reason the push would require publishing any email address.

 

EDIT: I configured my global Git email address using the noreply address. Now I get

error: failed to push some refs because the tip of your current branch is behind its remote counterpart. Integrate the remote changes...

 

UPDATE: I followed the instructions on the Git Handbook, under the heading 'Example: contribute to an existing repository'. Note: the 'git add' step did not work for me, but going to the next command was still possible. Uploading worked as expected using those commands.

 

I'd still like to figure out why the course instructions didn't work for me, and why the course bot allowed me to pass without uploading anything, so any thoughts would be welcome. Can I suggest an improvement to the course by using the commands from the Git Handbook?

1 Reply
Solution
Moderator
Message 2 of 2

Re: github-upload : failed to upload

👋 @tabasco-addict -- I like your handle!

 

Git history has to match exactly between the remote and local repositories for a git pull to work. The message:

 

> hint: ...the remote contains work you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (eg., git pull ...) before pushing again. See the note about fast-forwards in 'git push --help' for details.

 

Is likely because there was something changed on GitHub that wasn't changed locally. The .gitignore file was cloned to your machine (even if you don't see it on Windows) so that may very well be the file that was changed. It is hidden because dotfiles are hidden by default. This article may help show them. 

 

With respect to the bot allowing you to pass without uploading anything: the bot is looking for a push, which is triggered even if the push doesn't come from your local repository but rather from a change to the file on the web interface. It's likely that changing a file (like the .gitignore, for example) on the web, caused the push to trigger that step. This is "by the design" since we try to make sure our courses don't block folks from moving forward.