Git command moves me out of current directory into parent directory

I’ve been having an issue with git. When I execute a command it will push me out of the working directory and into the parent directory. This happens somewhat frequently, maybe 25% of any git command

So I will do something along the lines:

$user at ubuntu-machine in /var/www/project/name: git add .
$user at ubuntu-machine in /var/www/project/name: git commit -m "Git message"
$user at ubuntu-machine in /var/www/project/name: fatal: Not a git repository

I’m currently running Ubuntu 16.04 with git version 2.7.4.

Has anyone else had this issue? Possible reasons why it’s happening?

Any help is appreciated, thanks

  • Sudo git as another user with ssh-agent for key access
  • Any tool to see differences between version in git
  • Gitolite access repair
  • how can I do “git pull” automatically when my server startup
  • Sync existing project with remote server via SFTP , Eclipse
  • Error occurred while installing openstack : ./stack.sh:137:die
  • setup gitolite on mounted device - ubuntu
  • how to add ssh public key to a specific git repo
  • 2 Solutions collect form web for “Git command moves me out of current directory into parent directory”

    I resolved my issue by updating from 2.7.4 to 2.11.0

    sudo add-apt-repository ppa:git-core/ppa
    sudo apt-get update
    sudo apt-get upgrade git git-man
    

    it looks good to me as long as you initialized the directory…. if not then… you should initialize your directory first with:
    git init

    Git Baby is a git and github fan, let's start git clone.