-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] Share tips, tricks and custom commands with Fork community #961
Comments
Thank you for starting this topic. A bit later I will add some useful examples and a short roadmap. |
Here are some I use:
|
Right-click on a commit in the log and do a "fixup!" commit of the staged changes: {
"name": "Fixup! staged changes for '$sha'",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "commit --fixup $SHA",
"showOutput": false,
"waitForExit": false
}
}, |
Here is mine: [
{
"name": "Change author to me",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "commit --amend --author \"John Doe <[email protected]>\" --no-edit",
"showOutput": true,
"waitForExit": true
}
},
{
"name": "Open in ConEmu",
"target": "repository",
"action": {
"type": "process",
"path": "C:\\Program Files\\ConEmu\\ConEmu64.exe",
"args": "",
"showOutput": false,
"waitForExit": false
}
},
{
"name": "Open in Windows Terminal",
"target": "repository",
"action": {
"type": "sh",
"script": "wt -d \\\"$path\\\"",
"showOutput": false,
"waitForExit": false
}
},
{
"name": "Branches...",
"target": "revision",
"action": {
"type": "sh",
"script": "git branch -a --contains $SHA",
"showOutput": true,
"waitForExit": true
}
},
{
"name": "Find merge commit",
"target": "revision",
"action": {
"type": "sh",
"script": "git log --merges $SHA..",
"showOutput": true,
"waitForExit": true
}
}
] |
Mistaken |
@dsbert No they have not, the devil is in the details: rebase --rebase-merges != vanilla rebase |
Hi, I am using a custom command "git push -o merge_request.create ... etc.", the command itself automatically creates a merge request". |
This happens because "Everything up-to-date" is written to the stderr and the result window doesn't show error output by default. I need to think about how to handle this properly. You can see the full output in the activity manager (the button in the left bottom corner in the status control on the toolbar). |
|
I'm actively using these, but they require aliases from here (except "Copy path" file command). [
{
"name": "Fetch and rebase",
"target": "ref",
"refTargets": [
"localbranch",
"remotebranch"
],
"action": {
"type": "process",
"path": "$git",
"args": "febase $name",
"showOutput": false,
"waitForExit": true
}
},
{
"name": "Deliver",
"target": "ref",
"refTargets": [
"localbranch",
"remotebranch"
],
"action": {
"type": "process",
"path": "$git",
"args": "deliver $name",
"showOutput": false,
"waitForExit": true
}
},
{
"name": "Delete merged branches",
"target": "ref",
"refTargets": [
"localbranch",
"remotebranch"
],
"action": {
"type": "process",
"path": "$git",
"args": "del-merged $name",
"showOutput": false,
"waitForExit": true
}
},
{
"name": "Copy abbreviated commit SHA",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "cp-sha $SHA",
"showOutput": false,
"waitForExit": false
}
},
{
"name": "Copy commit full message",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "cp-message $SHA",
"showOutput": false,
"waitForExit": false
}
},
{
"name": "Reset files to here",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "reset-files $SHA",
"showOutput": false,
"waitForExit": true
}
},,
{
"name": "Fixup",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "fixup $SHA",
"showOutput": false,
"waitForExit": true
}
},
{
"name": "Copy path",
"target": "file",
"action": {
"type": "process",
"path": "$sh",
"args": "-c 'echo \"$filepath\" | clip'",
"showOutput": false,
"waitForExit": false
}
}
] |
Here is my 2 cents: make file executable for repository and {
"name": "Make file executable",
"target": "file",
"action": {
"type": "process",
"path": "$git",
"args": "update-index --chmod=+x $filepath",
"showOutput": true,
"waitForExit": true
}
},
{
"name": "Make commit archive",
"target": "revision",
"action": {
"type": "process",
"path": "$git",
"args": "archive --output=./$SHA.zip $SHA",
"showOutput": true,
"waitForExit": true
}
} |
I believe for change author it's better to use this |
@Lonli-Lokli Why is that better? |
@jerone because original command will change the author to the name specified, but the committer will be set to your configured user in git config user.name and git config user.email. I am still trying to understand what is the possible way to do it with some selected commits |
Checkout only one file from specific commit: [
{
"name": "Checkout file",
"target": "file",
"action": {
"type": "process",
"path": "$git",
"args": "checkout -m $sha -- $filepath",
"showOutput": false,
"waitForExit": true
}
}
] |
@kv1dr right click on a file in the 'Changes' view -> Reset File to state at commit. |
Oh, I didn't know that option exists. But it's still missing from File Tree tab. |
@Otiel how does your Rebase interactively with merges ever work? Since there's no GUI, every time I tried so far it has completely broken my Git into a corrupted state of half-rebase. Usually warrants restarting my machine to be able to manually remove rebase-folders under the .git folder. |
If you don't have an editor opening at step 2, that's probably because you're missing some config. If so, open the Shell from Fork (in order to modify the correct
(see here for other common editors) |
If you have
This will remove merged branches and update all other branches, without you having to switch to the branch and pull -- a great time saver :) |
Is there arg for previous SHA? thanks!! |
Has anyone figured out how to change the author of a specific commit and not just head? |
You can use So at a guess |
Nice file custom command to show the encoding of a file on Windows: {
"name": "file --mime-encoding",
"target": "file",
"action": {
"type": "process",
"path": "C:\\Program Files\\Git\\usr\\bin\\file.exe",
"args": "--mime-encoding $filepath",
"showOutput": true,
"waitForExit": true
}
} I'm not sure, if you have to install Git Bash to have |
@DanPristupov Would it be possible to support environment variable in paths:
Results in the following error: I expect it to resolve to (which I know exists):
|
@jerone I created an issue for this some time ago, please upvote it with a reaction 😉 |
This comes in handy when I want to do either powershell or bash profiles. Love that it opens a tab for either. "ShellTool": {
"Type": "Custom",
"ApplicationPath": "%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
"Arguments": "new-tab -p \"PowerShell\" -d . ; new-tab -p \"Bash\" -d ."
}, |
We had the problem that we have a public version, a public hotfix version, where people already can preview upcoming fixes AND another public version for upcoming features. We are using gitflow and extract the version number from the latest tag. What I came up with was another branch next to develop and master and a script to finish a hotfix into that branch (and also the others). This way we can have a separation between hotfix and new feature versions. export LANG=C.UTF-8
cur=$(git branch --show-current)
version=$(basename $cur)
if [[ $cur == $name ]]
then
echo You cannot finish $cur into itself.
exit 1
fi
if [[ $cur == master || $cur == develop ]]
then
echo finishing into master or develop is not allowed with this command.
exit 1
fi
echo checking out master and merging
git checkout master
git merge --no-ff $cur
echo checking out develop and merging
git checkout develop
git merge --no-ff $cur
echo checking out $name, merging and create tag $version
git checkout $name
git merge --no-ff $cur
echo deleting branch
git branch -d $cur
#for some reason the script stops after tagging
echo creating tag
git tag -a $version -m "Merge branch $cur"
echo FINISHED @DanPristupov EDIT:
|
I use a custom command to {
"name": "Merge (FF-only) into Current Branch",
"target": "ref",
"refTargets": [
"localbranch"
],
"action": {
"type": "process",
"path": "$git",
"args": "merge $name --ff-only",
"showOutput": true,
"waitForExit": true
}
} Just because I can't seem to find this documented anywhere (or perhaps missed it), |
Here is mine, Local PR without a commit so I can view consolidated changes
|
I fell in love with the Lean Branching idea, but I'm too lazy to press the UI buttons Sync, Finish, and then checkout back to the working branch, so I created a command that does all of that on one click: {
"action" : {
"script" : "commits=$(git rev-list --count develop..${ref})\n\ngit stash save\ngit update-ref refs/heads/develop refs/remotes/origin/develop\ngit checkout develop\n\nif [ $commits == 1 ]; then\n git merge ${ref}\nelse\n git merge ${ref} --no-ff\nfi\n \ngit push origin refs/heads/develop --verbose\ngit checkout ${ref}\ngit -c core.commentChar=^ rebase refs/heads/develop\ngit stash pop stash@{0}",
"showOutput" : false,
"type" : "sh",
"waitForExit" : true
},
"name" : "Lean Branching - Rebase '${ref}' onto 'develop'",
"refTargets" : [
"localbranch"
],
"target" : "ref"
} The command will also use merge --no-ff the same way as the Finish button does. Edit: also added automatic stash save/pop. |
I believe with custom commands many of us have a plenty variety of ideas how to enrich usability.
Lets share it with each other!
The text was updated successfully, but these errors were encountered: