96

I have a public Git repository on Bitbucket. I want to link the latest version of a Read-Me file. Here's the link to a revision/commit:

https://bitbucket.org/wordless/thofu-interpreter/raw/5bfc37864c5d/ThoFu%20Interpreter/ReadMe.txt

I tried to replace the revision number with tip and default, but it didn't work. Is there any way to get a permanent link to my latest files?

2

5 Answers 5

104

Two ideas:

Use master in the url (this seems to work):

https://bitbucket.org/wordless/thofu-interpreter/raw/master/ThoFu%20Interpreter/ReadMe.txt 

Another idea is to create a wiki page for your project, then use the wiki's functionality to link to the latest version of a file with this syntax:

<<file path/to/file [revision] [linenumber]>> 

Just omit the revision and line number parameters, they are optional.

Then, refer to the wiki page everywhere else you'd like link to the read me file.

Sign up to request clarification or add additional context in comments.

8 Comments

This also works linking to /src/ on bitbucket rather than raw bitbucket.org/user/repository/src/branch/path/file
@sunil-d Any idea how to that for private repo? When I click on raw url of a image in my private repo, it redirects to bytebucket.org & append a token so that it can be viewed publicly...like https://bytebucket.org/$username/$repo/raw/$sha/$filename.jpg?token=$sometoken. But the token is different for each file. Is there any way I can get/generate this type of token through bitbucket api?
@KhurshidAlam I'm not sure how that might work. A quick google search pointed to possibly using their API to get an OAuth token, but I doubt that is the same token used here (who knows). Sorry I couldn't help any further!
bitbucket.org/user/repo/raw/master/ReadMe.txt stopped working bitbucket.org/user/repo/src/default/ReadMe.txt works though
The Creole syntax : <<file path/to/file [revision] [linenumber]>> doesn't work for README files. The README files on Bitbucket only support markdown file.
|
38

There is an easy workaround for this issue by updating your relative links to src/[branch_name]/path/to/file. Works like a charm for me.

6 Comments

This should be used by default across the primary navigation. It is a much more common use case in my opinion.
The problem with that being the default is that it can become a 404, or refer to something completely different to what you intended.
Works great for me thus far, but it's early. @Antoine Pietri, how can it become a 404?
If you delete the file.
This schema doesn't work. Maybe it used to but it's not working anymore.
|
13

The canonical way to add a link to a file in your repository using Markdown (the default for Readme files and Wiki pages) is by linking to the relative path of the file.

For example, if I had a structure like so:

<repo root> |-- my-file.txt | |-- my-dir | |-- my-other-file 

I'd be able to link to them as follows:

[my-file](my-file.txt) [my-dir](my-dir) [some-other-file](my-dir/some-other-file) 

Bitbucket will then automatically link to the file at the current branch that you are viewing the file at. If you're viewing the Readme file in the overview that will mean the default branch (usually 'master').

2 Comments

Of all the above methods, this was the most succinct way of solving it.
And it can also be used in a markdown syntax way of adding the link at the bottom to keep the markdown clean
4

Here are working links:

RAW:

https://bitbucket.org/wordless/thofu-interpreter/raw/HEAD/TODO.txt?at=master&fileviewer=file-view-default 

Source:

https://bitbucket.org/wordless/thofu-interpreter/src/HEAD/TODO.txt?at=master&fileviewer=file-view-default 

Comments

3

I am using master like this for the last zip file of the code :

https://bitbucket.org/MIUSER/MIREPO/get/master.zip 

Where MIUSER is my user and MIREPO is the name of my app.

Hope that this works :D.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.