user9233770
user9233770

Reputation:

Can I export history of commands in git in file.txt?

I know how to copy the output of commands from git for example i will copy all branches that I created

git branch |clip

OR export it in a text file by this command

git branch > branch.txt

But the question can i copy all commands that I write it in a text file like matlab and where save in windows.

Upvotes: 0

Views: 2114

Answers (2)

iretex
iretex

Reputation: 69

DOSKEY /HISTORY | clip or DOSKEY /HISTORY > history.txt works for Windows Command Prompt

The first command clips the history to the clipboard while the next write out to a .txt file.

Upvotes: 0

Wouter de Kort
Wouter de Kort

Reputation: 39888

In Bash you can use the history command to display a list of all the commands you executed. You can also run history n where n is the number of commands you want to see.

Run the following to write the history content to a text file:

history -w ~/history.txt

By doing a grep on history you can filter it down to the commands that use git:

history | grep git

If you want to output the grep content to a file you can run:

history | grep git >  ~/history.txt

As a side note, the following PowerShell command gets all your PowerShell history and filters it to lines starting with git:

Get-Content -Path (Get-PSReadlineOption).HistorySavePath | Where {$_ -like 'git *'}

Upvotes: 3

Related Questions