In GIT, obtain commits using git log with path

I would like to obtain the last 10 commits using git log specifying the path of my repository. I used the option -path but I have “is outside repository” error

 git log --no-merges -10 -p /home/my_folder/git/repo

 fatal: /home/my_folder/git/repo: '/home/my_folder/git/repo' is outside repository

The comand is running for example in the folder /home

  • Font Awesome fonts displaying as boxes after Git clone/pull?
  • sh.exe": /bin/git bad file number when git -version
  • Moving committed git files to another directory
  • Refresh all files in buffer from disk in vim
  • How can I push a new branch?
  • An svn repo moved to git. I was using git
  • Override author on git merge
  • git svn - clone repo with all externals
  • How to synchronize fork with original GitHub project?
  • How to remove 'XXX$1.class' from git?
  • Git gets stuck on writing objects
  • How to create a proper patch when removing a function and its docblock with git
  • 2 Solutions collect form web for “In GIT, obtain commits using git log with path”

    Git assumes that the current working directory is inside the repository you want to operate on. When running a git command from outside the repository directory hierarchy, you can use the global -C option to git to specify which repository to use:

    git -C /home/my_folder/git/repo log --no-merges -10 -p

    Usually it’s probably easier to simply cd to your repository before running git commands.

    It’s worth noting that the -C flag for git log only appeared starting from git 1.8.5 and up

    For older versions of git here are your options:

    1.Manually move to the directory:

    cd /home/my_folder/git/repo && git log --no-merges -10 && cd - 

    2.Specify the --git-dir parameter:

    git --git-dir /home/my_folder/git/repo/.git log --no-merges -10
    Git Baby is a git and github fan, let's start git clone.