Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFarnoosh Johnson
7,887 Pointsgithub
when I try to push the changes in my local github repository I see this error messages in terminal!!! ''' To https://github.com/Farnoosh63/my_first_web_page.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/Farnoosh63/my_first_web_page.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. '''
any idea?
17 Answers
Kevin Korte
28,149 Pointswhat does it say if you run git status
Luke Pettway
16,593 Points"Updates were rejected because the remote contains work that you do hint: not have locally. "
Did you edit any of the files on Github? That message seems to indicate that you edited a file locally, but it is different on Github.
Farnoosh Johnson
7,887 Points$ git status On branch gh-pages Changes to be committed: (use "git reset HEAD <file>..." to unstage)
new file: LICENSE
new file: README.md
Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
deleted: .hello.html.swp
Farnoosh Johnson
7,887 PointsI did not change anything on github I only create a new repository and add read file and lisence
Luke Pettway
16,593 PointsThat is very odd. I see the files in your repo on Github, is the text inside the files you have locally the same as what is on Github?
Farnoosh Johnson
7,887 Pointsand when I type $ git commit this error will show up that I cannot do anything I have to close my terminal:(
''
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.
On branch master
Changes to be committed:
deleted: .hello.html.swp
new file: LICENSE
new file: README.md
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/Desktop/my_first_web_page/.git/COMMIT_EDITMSG" 9L, 260C
''
Luke Pettway
16,593 PointsAre you putting the -m flag and your message after the commit command?
git commit -m "this is my message"
Farnoosh Johnson
7,887 PointsI don't see any file except license and README.md in my repo!!! on github
Farnoosh Johnson
7,887 Points$ git commit -m "this is my message" [master 83b54a6] this is my message 2 files changed, 24 insertions(+) create mode 100644 LICENSE create mode 100644 README.md
Kevin Korte
28,149 PointsNow can you do git push origin master
?
Farnoosh Johnson
7,887 Pointsand this is my git status $ git status On branch master Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
deleted: .hello.html.swp
no changes added to commit (use "git add" and/or "git commit -a")
Farnoosh Johnson
7,887 Pointserror!!!
$ git push origin master To https://github.com/Farnoosh63/my_first_web_page.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/Farnoosh63/my_first_web_page.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.
Kevin Korte
28,149 PointsDid you ever delete the initial local git repo without deleting the remote repo on github, and than recreate a new local git repo and try to push to the already existing repo? That will screw this up like this.
Farnoosh Johnson
7,887 PointsI used $ git rm -r .git
Kevin Korte
28,149 PointsThat's your problem. You removed the original .git file the remote repo on github was using, and than recreated it. Now when you push, you get this conflict because the history doesn't match.
Farnoosh Johnson
7,887 Pointswhat can I do to fix this issue?
Kevin Korte
28,149 Points2 options, delete the old remote repo, and set up a fresh one, which isn't an option on bigger projects, or pull your changes from your remote repo, merge them with your local repo, and push them back to the remote
what happens when you git pull
Farnoosh Johnson
7,887 PointsI deleted all my repo on github
Farnoosh Johnson
7,887 Pointsi am going to start over,
Farnoosh Johnson
7,887 PointsI have these in my directory
$ls -a . .DS_Store CSS hello.html more info.html .. .git Images more info morestyle.css bradley-johnsons-imac:my_first_web_page bradleyjohnson$
Farnoosh Johnson
7,887 Pointsshould I remove .git and start over?
Kevin Korte
28,149 PointsNot neccesary, but you'll want to add the remote repo once it's created. Follow the directions here: https://help.github.com/articles/adding-a-remote/