Download single file from remote branch - github

Is there a way to download a single file from a specific branch of Git Remote repository?
Repo_URL:https://test.ghe.com/repo.git
Branch:release
Git relative file path: repo/file01.txt
There are many related threads however in none gives idea about how to use a specific Git remote branch.
Please help.
Thanks.
Kumarjit

To get the raw URL for your file, follow below steps.
1) Open your repo and required branch in github website.
2) Navigate to the folder containing your desired file.
3) On top of the file, you see "Raw" button.
4) Click on that and you see the raw URL in address bar.
5) You can use this URL to download the file, for example using curl.
However, I'm not sure about your use case, but it is always better to use git pull to get the file.
Hope this helps!

Related

How to create a new file in github and add there existing files?

I have files in repository. I want them to be grouped inside a folder. How can I do this?
It seems that I need to add new file if I want to create a folder.
From how you worded your question, it seems like you're trying to work on github directly from the website.
The usual way github works is:
if you have a repo on github and you want to modify it, first 'clone' the repo into your local computer,
use these instructions https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
then just change folder structure like you would normally on File Explorer (windows) or Finder (mac),
then follow the commit instructions and 'push' up your changes to github
use these instructions
check status of your recent changes:
git status
add the files that you want to include in the commit
git add nameOfFile
check status and the file you want to include should now be green
git status
use this to send to github
git push
Overall github docs here:
https://learn.microsoft.com/en-us/training/modules/introduction-to-github/

How do I get a new branch to show up in Eclipse Git Remote Tracking?

I have an existing Eclipse git project, with a master and development branch present in both local, and remote tracking. I have just added a new branch in my git repository, but I can't figure out how to get it to show up in Eclipse.
I have tried to read up on the subject, but it seems like it is just expected to automatically show up. I have found a lot of similar questions, but they all seem to deal with the issues of a completely empty remote tracking folder, instead of my problem of only a single new branch missing. I already have Master and Develop present.
Here is what does not work:
Clicking refresh in the Git repositories window.
Any kind of synchronize, pull or other update I can find
Here is what would work:
Right clicking the remote tracking folder, and selecting "Paste repository path or URI". If I do that, and select the exact same path as is already there, I can see my new branch. This action does require that I completely clone the whole repository to an empty folder again, and that can't be how this is intended to work.
I believe it might work to use some kind of command line tool, but I really want an Eclipse solution to this, as I feel sure it exists, and I am just missing something.
In the Git Repositories view:
Right-click the repository and choose Fetch from Upstream
If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
Right-click the fetch node below Remotes/origin and choose Configure Fetch...
In the Configure Fetch make sure there is only the single Ref mapping (assuming the remote is named origin) +refs/heads/*:refs/remotes/origin/*:
In case you do not see Fetch from Upstream after right-click the repository, you may look for Fetch from origin.
For me the solution was almost what Joshua suggested, however it did not work as described. For me the solution was to configure the [remote "origin"] property as follows:
[remote "origin"]
url = your_git_url.git
fetch = refs/heads/*:refs/remotes/origin/*
Alternatively, you can do it from the Eclipse UI too:
Fetch from origin... then hit Configure... and in the configuration window hit Advanced... and there you have the option to Add predefined specification where you can selec Add All Branches Spec. This will result in the same configuration as above:
Maybe you have to remove your original entry which will be pointed out as a duplicate by Eclipse.
You need to modify the "config" file in your local git repository folder. For example, you cloned a remote branch Project into c:\git\MyProject local folder. In this folder there is a hidden folder ".git" that has a "config" file. There is a section in this file resembling the below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/Project:refs/remotes/origin/Project
You need to modify this section as below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/:refs/remotes/origin/
Then go back to Eclipse IDE, right click on the repository and do a "fetch from origin". Now all the branches will show up.
What I did:
1: disconnected.
2. refresh and pull. Then, it shows the new branch
3. create local and pull.

New to git--just need to sync one file

I managed to finally get EGit in Eclipse to work (still don't know how) and I've committed/pushed my current project up to GitHub. So far, so good. Looking at it on GitHub's site, I see it wants me to make a README.md file to provide a nice description. Fine, I think, I'll just use the tool it's providing me with to get it started, then have it sync back down to my local computer where I can further modify it and keep it synced.
So I created a quick README.md file on GitHub's site. But now, when I perform a "Pull" action in Eclipse, I am told that there's nothing new to pull, or something like that. Why is it not getting the new file that was created on GitHub's site, and how can I get it so that I can make changes to it whenever I want?
If you have git installed you can use a terminal and type in the root of your repository:
git pull origin master
or you could try checking out only that file:
git checkout README.md

Fossil-SCM Pulling only a specific file

I was trying to pull only a specific file from the fossil scm but the only reply I got was
Fossil internal error: repository does not exist or is in an unreadable directory: blahblah
the commands I tried to use was
fossil pull "file" -R "http://user#ip/folder/to/fossil"
fossil pull "" -R "http://user#ip/folder/to/fossil/file"
I don't understand the documentation. If I wanted to just download a specific file without opening and cloning the repo, how would I do that?
You can't pull a single file from a fossil server. Pulling retrieves ALL the (new) changes in the remote repository into your local repository. It's the read part of the sync command, and it requires you to have cloned the repository first. (The -R command-line option always indicates a local repository).
But it seems to me that what you want, is simply to download a specific file from the remote repository. To do that, just use your browser to navigate the fossil server's web site (I'm using Fossil's own source code repository as an example):
http://fossil-scm.org/fossil/dir?ci=trunk
http://fossil-scm.org/fossil/tree?ci=trunk
and click on the file you want. On the page displaying the file, there's a Download button which will let you download that version of that specific file.
If the file is not text or HTML, you can just download the file using http, using a so-called documentation URL:
http://<server>/doc/<version>/<path-to-file>
For example, let's say you want to download the trunk version of the file www/concept1.gif from the main Fossil repository. That can be achieved by downloading the following URL:
  http://fossil-scm.org/fossil/doc/trunk/www/concept1.gif
That URL is composed as follows:
http://fossil-scm.org/fossil is the repository's location;
/doc/ indicates that you want to access the repository's files directly;
trunk indicates the check-in you want to access. This can also be a check-in identifier (like e319e8e870) or a tag (like pending-review). If you specify a tag or branch name, you'll get the file associated with the last check-in with that tag, respectively in that branch;
/www/concept1.gif is the path within the repository to the file you want to access.
Note that if the file you requested is a wiki, text, or HTML page, fossil will add its header and footer to it.

How do you completely remove a file on github

I've seen the command needed to remove a file and erase it from the history on git. Is there a way to do this with the github website? If not, it looks like I need to know where the file is to do it with a git command. Where does github store the local repositories?
See: https://help.github.com/articles/remove-sensitive-data
To get a local version of the repository, look up the URL from the repo page on Github and clone as explained in the link above.