How to get Git last commit message from one working directory to github repo


need to get the last commit message from one working directory to git repo locally. Thank you

Hi, I’m afraid it’s not really clear what you’re trying to do. Could explain in detail so people can help?

Assuming you have two related git repositories, you can do:

git push ../../path/to/other/repository HEAD:new-name-in-destination-repository

Thanks for the response. I was executing the git log -1 command in repo ‘A’ and then get the last commit message of that. But I want to fetch the last commit message of remote repo ‘A’ through local github repo.

If the remote repository is configured as a remote in your local repository, you can tell git log to look at a remote branch, e.g. to check the main branch of remote origin:

git log -1 origin/main

Note that this doesn’t update remote repository information, if you want to do that run git fetch on that remote first.

1 Like