I can find this information using GitLens extension and by using the command line, but using the standard VSCode Git menu/sidebar, how do you find out the remotes attached to the current folder? It doesn't seem to want to tell me this anywhere obvious. I've tried hovering, using the '...', clicking the status bar, etc...
thanks.
There doesn't appear to be anything to only print the remotes, but digging around in commands.ts, I found this sequence that may suffice.
First, use the Command Palette (Ctrl+Shift+P) to run "Git: Pull From..." (internally known as command.pullFrom):
With multiple folders open, this will prompt for which repo to query:
It appears that the initially selected repo is always the one containing the active text editor, so you can just hit Enter immediately. If only one folder is open, that step is skipped.
This displays the "Pick a remote" choice:
This lets you see your remotes, along with their URLs, which is what I think you wanted to see.
Just hit Esc to cancel out so you don't actually pull anything.
Related
Sometimes I want to provide a link to some source code in the comment to an issue.
If I open repository in browser and find the fileI need, the link refers to master branch by default. It means that over time the code referred by the link will change, because the master will move together with commits history.
In GitHub and GitLab when you want to get a permanent link on a file you just opened, it is enough to press y on the keyboard and the link will switch from referring the master branch to particular commit hash it points to.
I.e. https://github.com/octocat/Hello-World/blob/master/README -> https://github.com/octocat/Hello-World/blob/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d/README
At work I use BitBucket server (v7.10.1, if it matters) and unfortunately the y does not work, and I also do not see any button on UI to get permanent link. How can I achieve the same result (get permanent link) on BitBucket server?
I know a couple of tricks I am not satisfied with:
using Bitbucket Linky plugin for Intellij, but I want a more light-weight way
pressing History button on a file, and choosing the most recent one (but it does not give you the master hash, it gives the hash of the last change of the file. And also this button won't work if the file has a single version and never changed after the 1st commit)
Got to the version you want, and then click 'Raw file' (top right hand side of screen)
The path in the address bar should now be a permanent link. It will be the raw version of the file unfortunately, but it is a permanent link.
I create a tutorial, where I want to introduce some testing frameworks like Mockito, WireMock and EasyMock. I want to explain it step by step. Additionaly I want to provide examples, where the reader of the tutorial can try to recreate these. Therefore I want to to give them the opportunity to look into my source code and use it when they are not able to recreate the test. And then they can use the actual version to continue and then again, when they are not able to create the next test, I want to to give them the possibility to use my new version with the new test.
My idea is to use different commits and link them to the tutorial. How can I do this or is there any better approach to reach what I just explained?
Easy Peasy!
The basic approach is this: browse to exactly what you want on GitHub, and then share the URL. GitHub URLs are stable permalinks, even when you navigate to an old revision or another branch.
Open the repo in Github.
Browse to Branch, tag or commit you want.
For branch/tag, there's a drop down in the upper left of the files listing.
For a specific commit:
Click on Commits at the top of the files listing. This will take you to a page showing all the diffs. (You can share this URL if you want. Otherwise continue to the next step.)
Clink on Browse files in the upper right corner.
You are now looking at a repository view just like the one where you started, except this view is of a specific branch, tag or commit. It's like a GitHub time machine.
If you want to link to the entire repo at this branch/tag/commit, copy the URL right now.
If you want to link to a particular file at this branch/tag/commit, navigate to the file in the listing, then copy that URL.
If you want to link to a particular line in the file, click on a line number, then click on the ... button that appears next to it and then click Copy permalink
If you want to link to a range of lines in the file, hold down the shift key and clink on the other end of the range of lines. The lines will be highlighted. Click on the ... button that appears next to it and then click Copy permalink
All that said, unless you are walking them through your many iterations of the code, I'm not sure giving them links to versions in git history is the way to go. Let's say they want to clone your repo. Then they'd have to git checkout example-2-version-3 or something.
The more typical approach is to put the different versions in a directory hierarchy, making it far easier to browse, whether on GitHub or a local clone of your repo.
I want to link to a line of code in such a way that the link will continue to work even when the file is updated in future commits.
In Github I would do this by pressing 'y' to move to a version of the page that includes the blob SHA:
https://github.com/rails/rails/blob/b49e38b76b0998b0a8312d8c08c98728d3de2006/activerecord/lib/arel/attributes/attribute.rb#L30
(Alternatively GitHub has a 'copy permalink' option in the '...' menu that appears in the margin when you select a line - documented here.)
Is there an equivalent in Azure DevOps?
The link that I get when I select a line has the form:
https://.../_git/project?path=XXXX&version=GBmaster&line=426&lineStyle=plain&lineEnd=427&lineStartColumn=1&lineEndColumn=1
Lots of parameters defining the selection but nothing pinning the file version.
Edit:
The below illustrations can be summarized in a few keyboard shortcuts.
Open the repo Files view using the 'e' global shortcut
Use 't' to put focus on the path selection to quickly navigate to the file in question
point 2 and 3 are order agnostic in relation to one another
Use 'y' to change the Files view to be based on the latest commit instead of on the branch
Make selection
Copy link as shown in illustration below
Browse files on the commit
Make sure you're browsing the entire source for the commit. Selecting lines when viewing the commit itself (ie AzDOs fancy git show) is for adding comments to the commit, but it doesn't help produce a link to the line # that version, nor is there a way (at least not that I could find) to get a link to the comment made on the line. Getting a link to a comment on a line in a commit might have been helpful to provide additional direct context to what is linked and why, but that's also not what you asked for.
don't click on the commit itself
make sure you're browsing all files as of a commit (not a branch)
Make selection
You should be able to select a line in the file contents and get a link to that line(s) in that version.
note: the link produced here is even more lengthy than the one you provided in your question.
Joy
When you navigate to the copied link, you will be directed to the commit and file contents with the line highlighted.
Understand, this link is bound to the commit you used to create it not to the tip of the branch. I expect this was how links are surfaced to be more sure that the link wouldn't break or lose context as the commit at the tip of the branch changes over time.
Thank you #JoshGust. For anyone else who wants the abbreviated version:
Files -->
(your repo branch) -->
History -->
Click A Commit hash/number (Latest/Head usually) -->
Browse Files -->
Your file -->
Select text & get a link.
Sheesh... quite some hoops to jump through, but glad it's possible.
To create a web (repository) link to a specific line from within your IDE, there are extensions with options to link to files, selections, to a branch or to a specific commit.
I am using these ones:
Editor
Plugin
Visual Studio Code
Git Web Links for VS Code
Visual Studio 2022
Git Web Links
I have a GitHub repository where I put my jupyter notebooks in it. While I open my notebooks in GitHub, I usually see a pencil button where I can Edit my notebook:
However for some other notebooks in the same repository it disappears:
Why this happens and how to fix it?
It is simply because of the size of the file. Github does not allow editing large files (not sure what is the exact size limit) It sometimes even restricts viewing such files, and they can be viewed only in the raw mode.
To edit these files, edit them in your local clone and push them to the desired branch using git cli, Github Desktop, SourceTree etc.
Edit: Answer is outdated now. Please see the workaround mentioned in comments.
As per Wayne Bloss' comment, it's actually possible to exchange the blob to edit in the URL and edit files that have the edit button hidden.
https://github.com/orga/repo/blob/branch/folder/filename.extension becomes https://github.com/orga/repo/edit/branch/folder/filename.extension
In my case, it was a lifesaver because I couldn't checkout the file on Windows due to an illegal character in the name of the file.
Is it possible in EGit to see the simple history of a file?
Team > Show in history shows all commits to all files. Not useful.
I am looking for the history of a file. There is a button in the History view that says Show changes to selected resource but no way to select a resource.
There also does not appear to be any way to compare with a specific version unless that version has a tag.
The pieces seem to be there, but are they put together properly?
(No complex branching or other cleverness. I normally use the command line for this type of work but should not have to.)
You can open a file (or select it from project explorer) and do:
Right Click -> Team -> Show in history. This will open the following view:
The filter circled in red is: "Show all changes of selected resource and its children" which basically will filter only the commits that relate in any way to the resource you've selected (you can chose the different filters to get a better understanding of how they differ from each other).
The problem was that the Team > Show in History needs to be run from the Project Explorer window. When I first found those scoping buttons I right clicked on the class file's edit window and did the Team > Show in History there. That appears to be broken and only shows all changes.
(Thank you for your replies. Knowing that it could be done and by those scope buttons let me look further. I rarely use the Project Explorer, preferring to just type the class/file name into the Navigate dialog.)
Some other answers suggest clicking on Team > Show in History. This menu item does not show up. Instead, Team > Show Local History shows up.
I have Git Staging tab open all the time. I saved a small change to the file I wanted to see the history of. This caused the file to show up in the Unstaged Changes in Git Staging. I then right-clicked on the file, clicked on Show In and then History. This showed me the history of the file according to Git.