Add another file to existing GitHub Gist - gist

I've got an existing GitHub Gist, and I'd like to add another file to it.
The data model for the GitHub Gist API indicates that more than one file can be added to a Gist.
How can I accomplish this?

Go to your Gist and click the Edit button at the top right.
The Gist editor will show your files in edit mode, then look at the bottom left and there you will find an 'Add file' button.
Click it and the cursor will be moved to the 'File name box..', type a name and click the 'Update gist' button at the bottom right.
:)

Click Edit
...and then Add file

https://developer.github.com/v3/gists/#edit-a-gist
Note: All files from the previous version of the gist are carried over by default if not included in the object. Deletes can be performed by including the filename with a null object.
^So just pass the files object containing your new file with the PATCH request and it will be added to the gist

A command-line alternative is to clone the gist, add the file to the index, commit the change to the repository, and push the update to the remote repository:
git clone https://gist.github.com/…
git add …
git commit -m "…"
git push
In the interim, if the gist is altered using the site's ✍ Edit button—say to update the gist's description—simply pull in the change when next at the command-line:
git pull
In this complete example, the file JDBCPieTest.java was added to the original gist. Examine the log to see the effect:
git shortlog
trashgod (7):
<none>
Add JDBCPieTest.java.
<none>
Add JDBCXYTest.java.
<none>
Rename JDBCTest.java -> JDBCCategoryTest.java.
Refactor JDBCPieTest.java.

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 my site to show up through github?

I uploaded my files to github, checked off readme, commit changes, selected masterbranch, and I got the following message as I scrolled down the page: Your site is published at https://tanishav842.github.io/Recipes/ but there is nothing there except for the word Recipes, which appears at the end of the site address that had been established for me through github. What did I do wrong?
Well, Tani, to have your own page hosted by GitHub Pages it need to be stored in one of the following places
In a public repository named <your-github-username>.github.io
Under a docs folder in master branch of any public repository you own
In gh-pages branch of any public repository you own
It means your Recipes repository are pretty much there.
Just copy your master branch content to a new branch named gh-pages and push it:
git checkout -b gh-pages
git push -u origin gh-pages
In addiction, as commented Edric, it would be cool to have your pretty nice stuff added to your page.
By now, I suppose GitHub is using your README.md that just have the word Recipes there!
Anyways, Here you can find a bunch of details about Working with GitHub Pages and also some step-by-step tutorials to learn how to do it properly
Hope this can help you!
Hosting a site is better supported by the GitHub application. Try following these steps to see if they help:
Download either GitHub for Mac or GitHub for Windows, depending on your operating system. Open the app and log in using the account you just created.
(On Mac): After you login, click advanced and make sure that your name and email are correct. Then, click "Install Command Line Tools", just in case you want to start using the command line later in life.
Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the "Push to GitHub?" box is checked.
Move your website's files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level directory.
Back in the GitHub application, you should see your files in the left column. Make sure they are all checked. If so, enter a message in the text box called "commit summary", something like "initial commit." Then, click the commit button.
Click the "Publish repo" button in the top right corner.
Give it about 10 minutes, then check your-username.github.io. Your website should be there!
Here's the reference link:
https://gist.github.com/TylerFisher/6127328

How to delete a file from GitHub history without using commandline

I need to remove a file from history. I don't have commandline access to GitHub. Kindly help if this can done through UI itself.
You can't delete the file from history, but you can delete it from the repository by following this help article
Alternatively, you could do a cherry-picking using one of the Git GUIs software, then cherry-pick all the commits, except for the one that you wanted to removed, into a new branch. Then, delete the old branch.
TO achieve this, you have to have command line access.
Delete file from history
But Using UI , you could delete the file from the repo (branch)
Ex:
Click the delete button on top right corner and commit.
You don't need command line access to GitHub, only to your own local clone, where you can:
either do a git filter-branch (example here)
or use BFG
Then you git push --force.
But the alternative, if you really don't want to use any command line, even locally... would be to contact GitHub support, asking them to remove the file from your remote repo history.
That is a last resort option though, since you are supposed to be able to do that on your own.

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.

Integrating Eclipse and GitHub

I am in need of help in trying to setup Eclipse so that I can push my code onto my GitHub account. I've searched online and the tutorials I have found are either outdated or don't work for me.
I already have a project on Eclipse. How would I put that code onto GitHub? Would someone please add detailed instructions please. Any help is appreciated.
EDIT
As soon as I posted this question, and fiddling around with the settings I managed to get it to work! What a coincidence...
The only problem I have now is how do I set it up so that when I commit it will only select the files in the project folder? Right now it is showing all 600 files in the Package Explorer.
Alright, there are several ways of doing this. I found this to be the easiest way:
First, set up SSH2 configurations. Go to Windows->Preferences->General->Network Connections->SSH2->Key Management and Generate RSA Key. Save Key
Copy that key. You will need to go to your GitHub account settings and add the new SSH key to your account.
Now, you need to install eGit:
Next, you want to add the Git Repositories view:
Create a new Git Repository. I have already created a repository called Java. I will refer to that repo for the rest of the explanation.
After you create your repository, it should show up in the Git Repositories view. Now to add your project to the repository, right click on your project and select Team->Share Project.
Select the repository you just created. You can also use CTRL+ to select multiple projects and place them in one repository.
Now go back to your Git Repositories view. Go to Remotes . Right click and select Create Remote.
Select Change... and enter the SSH link for your Repository on GitHub.
For connection, select SSH. Then press Finish.
For Rev-mapping, select Advanced....
For Source Ref select refs/heads/master. And then press Add Spec, then select Save specifications in 'origin' configuration. Then press finish.
That's pretty much it. You can commit changes by right clicking your project - >Team->Commit...`
Push new commits to GitHub:
This is a really good explanation on how to set up Eclipse pull requests.
The current branch is not configured for pull No value for key branch.master.merge found in configuration