cis-ds / Discussion

Public discussion
10 stars 15 forks source link

RStudio won't let me push (I think because "my current branch is behind its remote counterpart") #139

Closed iallum closed 4 years ago

iallum commented 4 years ago

I've been working on the hw assignment and I think I have it finished so I want to push it to git, however, RStudio isn't letting me do that. I've already committed and pushed a few times before, but all of a sudden it won't let me anymore. The error message says:

To https://github.com/iallum/hw01.git ! [rejected] HEAD -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/iallum/hw01.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I also have a notification above my environment/history pane that says: your branch is ahead of 'origin/master' by 2 commits

bensoltoff commented 4 years ago

Hmm, not sure why you are getting that message. It implies there are commits in your copy of the repository on GitHub that do not exist in your local copy.

Try pulling the repository first before pushing. We don't really use pulling in the usual workflow, but essentially this means pulling changes from GitHub down into your local copy. There is a button in RStudio right next to the push button that lets you do this.

Screen Shot 2020-06-23 at 1 36 04 PM

Try pulling, then push again. If you get more error messages, post them here

iallum commented 4 years ago

tried to pull and got this message:

/usr/bin/git pull Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result.

bensoltoff commented 4 years ago

Check your README.md. There will probably be a couple of sections which look very odd, something like this:

If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a

You need to fix the text within those <> brackets to be the version you want and delete the brackets. Essentially figure out what version of the document you want. Once you do that, stage/commit/push one more time. This should now allow you to push your changes to GitHub

iallum commented 4 years ago

it did let me push, but it committed a version with the bracketed section and both versions of the code, not one with the edits I made. and when I tried to push it again (thinking maybe I had accidentally committed and therefore pushed before editing), it just tells me everything is up to date even though it doesn't appear to be.

bensoltoff commented 4 years ago

Did you stage/commit the saved file after you edited it?

iallum commented 4 years ago

yes i thought so -- I also don't see a README.md thing in the environment/history box anymore (I think there was one there before?)

bensoltoff commented 4 years ago

I'm pretty sure this is the version of the document you want

---
output:
  html_document: default
  pdf_document: default
---

# hw01

### Self-Introduction   
![](images/profile pic.png)  
Hi! My name is **Izzy Allum**, and I am a first year at the University of Chicago. I'm from Washington, DC, so that's where I've been spending quaratine. My hobbies include:  

* fencing (I'm on the club team at UChicago)
* baking and cooking
* listening to music
* listening to [Spotify](https://open.spotify.com/) and watching [Netflix](https://www.netflix.com/browse)
* occasionally doing some arts and crafsty stuff!

Copy this into your README and replace the original contents, save, stage, commit, and push (yes I know that sounds a bit tedious). That should fix the problem though.

iallum commented 4 years ago

thank you so much! one last question: when I preview the markdown on my own computer, the picture i added shows up, but when I look at it on github, it doesn't. is this supposed to happen or am I missing something (I figure I very well could be since I just googled how to add images and did a bit of trial and error)?

bensoltoff commented 4 years ago

It's not converting the markdown to the necessary image output. Try adding blank lines before and after that line of text in the document.

You may also need to rename the file so it doesn't have a space in the name. Some computers don't like whitespace in file names

iallum commented 4 years ago

I tried doing both of those, and something changed because there is no longer a line of text there, but there still isn't a picture showing up on github.

iallum commented 4 years ago

I have the image in a folder in my hw01 folder, do I perhaps need to commit and push this image/folder to github?

bensoltoff commented 4 years ago

Yes

bensoltoff commented 4 years ago

Right now the version on the site has a good URL, but you haven't changed the file name of the image yet. So essentially the embedded image has a broken link

iallum commented 4 years ago

thank you so much! It's all working now.