
Question:
Using the GitHub application on Mac (not the cli), I have this error which I don't really understand and don't know how to fix. I know its an error because the application throws up a window that says "GitHub Error". I need to commit the changes to the files listed below, but GitHub won't let me. When I press the Commit button, the error appears and it seems I can't do anything to fix it. Any help would be great.
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .gitignore
# modified: haystack.egg-info/SOURCES.txt
# modified: haystack/__init__.py
# modified: haystack/search.py
# modified: haystack/static/css/layout.css
# modified: haystack/static/images/classifications/G.png
# modified: haystack/static/images/classifications/M.png
# modified: haystack/static/images/classifications/MA.png
# modified: haystack/static/images/classifications/PG.png
# modified: haystack/static/images/classifications/R.png
# modified: haystack/static/images/classifications/X.png
# modified: haystack/templates/base.jinja2
# modified: haystack/templates/base_page.jinja2
# modified: haystack/templates/search.jinja2
# modified: haystack/templates/search_results_episodes.jinja2
# modified: haystack/templates/view_episode.jinja2
# modified: haystack/templates/view_program.jinja2
# modified: haystack/view.py
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# haystack/static/images/classifications/G.pxm
# haystack/static/images/classifications/M.pxm
# haystack/static/images/classifications/MA.pxm
# haystack/static/images/classifications/NA.png
# haystack/static/images/classifications/PG.pxm
# haystack/static/images/classifications/R.pxm
# haystack/static/images/classifications/X.pxm
# haystack/static/images/haystack_logo.png
# haystack/static/images/test_key_art.jpg
# haystack/static/images/test_thumbnail.jpg
# haystack/templates/view_asset.jinja2
# haystack/templates/view_assets.jinja2
no changes added to commit (use "git add" and/or "git commit -a")
(256)
Answer1:By this message, git
tells you that your local commit tree is ahead of repo in github.com.
Repo in github Your local
Y <-+
| | ahead of 2 commits
Z <-+
|
commit A <----------------> A
| \ | \
B D B D
| / | /
C C
| |
Seems this is output of git status
. You can just git add
your changes to stage area
, and then use git commit -m "your message"
to commit this code to your local repository.
If you want to put your work back to github.com
, use git push
.
It is not an error. GitHub app does a fetch when you use, which you normally might not have done. Hence when you do git status
, you now see that the remote master actually has moved ahead by 2 commits. Just follow you same workflow. Or use the sync
feature of the GitHub app after committing.
If you want to discard changes to your local master branch and pull master from remote (github) do the following:
<ol><li>git reset --hard</li> <li>git pull</li> </ol>