简体   繁体   中英

Cant push or pull to my own Github repository

Im very new to using git and github but I've read the docs and followed all instructions and still dont seem to be able to commit and push my changes to my own repository on Github here https://github.com/davejonesbkk/flask-intro

When I try to push using 'gut push origin master' and after logging in it returns the following:

To https://github.com/davejonesbkk/flask-intro
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/davejonesbkk/flask-intro'
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.

so then I tried to do a 'git pull origin master' as advised in the github docs and it returns the following:

From https://github.com/davejonesbkk/flask-intro
* branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten    by merge:

app.pyc
config.pyc
models.pyc
posts.db
sample.db
saple.db
test.pyc
venv/.Python
venv/bin/activate
venv/bin/activate.csh
venv/bin/activate.fish

and then maybe a hundred lines or more of basically all the files etc from the root directory of where the app is stored locally and then this:

Please move or remove them before you can merge.
Aborting

however I read that I should be able to get round this problem by having a .gitignore file in my root folder which I already have and this is its contents:

*.pyc
venv
.DS_Store
blog
*.db
coverage
tag.py

Ive read some other questions here on SO about this problem and they all advise using a .gitignore file but I have one so what else do I need to do?

In case it helps this is also the output of my branches and remote branches:

(discover-flask)Davids-MacBook-Air:flask-intro david$ git branch -a
* master
  remotes/heroku/master
  remotes/origin/master
  remotes/upstream/master

(discover-flask)Davids-MacBook-Air:flask-intro david$ git remote -v
heroku  https://git.heroku.com/calm-falls-6315.git (fetch)
heroku  https://git.heroku.com/calm-falls-6315.git (push)
origin  https://github.com/davejonesbkk/flask-intro (fetch)
origin  https://github.com/davejonesbkk/flask-intro (push)
upstream    https://github.com/davejonesbkk/flask-intro (fetch)
upstream    https://github.com/davejonesbkk/flask-intro (push)

Ive pushed successfully to this repository a while back but that was over a month ago and when following a tutorial and Im not sure whats changed since then, as you can see I've also pushed to Heroku since then but that was also done while following a tutorial.

Im on a Mac btw and trying to push files for a Flask app when using virtualenv.

Any help would be greatly appreciated!

如果正常的push command is not working首先拉回仓库,然后使用push -f命令。

For applying you .gitignore file use this

$git add .gitignore

Commit your changes(don't forget use git add command if you have added some new files in your project)

$git commit -am"my commit"

After that try pull one more time

$git pull origin master

Anyway read more about git reset and it --hard key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM