In GIT, get a commit using the git log with the path

I would like to get the last 10 commits using the git log defining my repository path. I used the -path option, but I have an "out of 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 command works, for example, in the / home folder

+3


source to share


2 answers


Git assumes that the current working directory is inside the repository you want to work with. When running the git command from outside the repository directory hierarchy, you can use the global option -C

for git to specify which repository to use:

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

      



Usually, most likely just cd

to your repository before running git commands.

+6


source


It is worth noting that the flag -C

for git log

appeared only starting with git 1.8.5 and higher https://git-scm.com/docs/git/1.8.5

For older versions of git, the following options are given:

1.Tune into the directory:



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

      

2. Set the parameter --git-dir

:

git --git-dir /home/my_folder/git/repo/.git log --no-merges -10

      

0


source







All Articles