My Favorite Git Trick
Posted on November 2, 2022 by Michael Keane GallowayA couple of months ago a manager kicked of an interesting Teams discussion. He started tossing out git tips and tricks while encouring others to share theirs as well. The following is from my contribution to the discussion.
We’re using an on-premise TFS server configured to supply our development teams with git repositories via HTTPS. With this set up, there’s a few different scenarios where the URL for the repo on the TFS server is shown. For example, we see the URL in the output from git push
.
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 12 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 435 bytes | 217.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Analyzing objects... (5/5) (7 ms)
remote: Storing packfile... done (51 ms)
remote: Storing index... done (115 ms)
To https://internal.tfs.server.com/InternalCollection/InternalProject/_git/propriatary-repo
e72f1f7..d3cae6e main -> main
In my terminal emulator, I can then ctrl+click
the URL and land on the web page for the repository. Then there should be a button prompting me to create a PR for the branch that I most recently pushed code to.
If I haven’t pushed code lately, then I sometimes use git remote
with the verboxe flag, and then click on either of the URLs shown:
> git remote -v
origin https://internal.tfs.server.com/InternalCollection/InternalProject/_git/propriatary-repo (fetch)
origin https://internal.tfs.server.com/InternalCollection/InternalProject/_git/propriatary-repo (push)
In the spirit of that internal Teams thread, I hope other developers can get some use from this trick as well.