Troubleshooting misplaced .git directory (nothing to commit)

后端 未结 16 1340
死守一世寂寞
死守一世寂寞 2020-12-05 01:42

I started getting this message. No matter what I edit and try to commit, it says there is nothing to commit. Looks like git does not see my working directory and looking som

相关标签:
16条回答
  • 2020-12-05 02:27

    This must have happened because by mistake you reinitialized git in the same directory. Delete the .git folder using the following command Go to repository you want to upload open the terminal and then use the following commands

    1. remove the .git repository sudo rm -r .git
    2. Now again repeat from initializing git repo using git init
    3. then git commit -m "first commit"
    4. git remote add origin https://github.com/user_name/repo
    5. git push -u origin master After that enter the username and password and you are good to go
    0 讨论(0)
  • 2020-12-05 02:29

    I had the same issue. The branch I was working on wasn't being tracked. The fix was:

    git push orgin
    

    This fixed it temporarily. To make the changes pertinently I:

    git config push.default tracking
    
    0 讨论(0)
  • 2020-12-05 02:29

    if .git is already there in your dir, then follow:

    1. rm -rf .git/
    2. git init
    3. git remote add origin http://xyzremotedir/xyzgitproject.git
    4. git commit -m "do commit"
    5. git push origin master
    0 讨论(0)
  • 2020-12-05 02:31

    On branch master Problem it is committed already nothing to commit (working directory clean) if faced this problem then just only use the following command

    git push -u origin master
    

    or

    git reset
    git add .
    git commit -m "your commit message"
    git push -u origin master
    
    0 讨论(0)
提交回复
热议问题