How to search for commits containing a specific word or sentence

git log --grep="Text you are searching for"

How to show all the commits that contain a specific file

This command will not show commits past a rename of the file.

git log -- path/to/file.txt

 This command will show commits past a rename.

git log --follow -- path/to/file.txt

How to show changes between local and origin

git log origin/master..master

How to show the files that is different between two branches

"HEAD" in the command is for the current checked out branch.

git --no-pager diff --name-only HEAD origin/master

How to show all commits

For a specific branch

git log origin/master

For current checked out branch

git log

For all branches together

git log --all

How to pull a file from another branch to the checked out branch

git checkout origin/master "path/to/file.txt"

How to get an patch file at github and apply it to checked out branch

On github go to commit you want to create patch file of then do the following steps.

  1. Open the commit in Github in your browser
  2. Change the URL as follows. Example commit URL "https://github.com/joomla/joomla-cms/commit/0aba9c89701154c215d3d26f2597396e4c1e9ee2" then add .patch after the URL as follows "https://github.com/joomla/joomla-cms/commit/0aba9c89701154c215d3d26f2597396e4c1e9ee2.patch"
  3. Then save the patch file by right clicking on the content that is showing in the browser and choose save as.

To apply the patch file to your current checked out branch use the following command

git apply -3 path/to/file.patch

Hope this helps

Cookie policy

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Cookie Policy