Download commit messages from project in GitHub - github

I have a project in GitHub and during the last years I have committed several changes to the project. In each commit I was adding a small text about the commit (e.g. fix problem with function A).
Is there a way to download all the commits that I have committed so far ?. I don't want to download the changes of the code of each commit, just only the text that I was writing.. Is this possible?

GitHub has an API for that.
https://api.github.com/repos/(username)/(repository)/commits
See REST API v3: Commits
List commits on a repository
GET /repos/:owner/:repo/commits
You can then just read all message keys in the commit objects
Edit:
If you try to do that on a private repository, you have to make an authentication first.
Basic example with curl:
curl -u username:password https://api.github.com/repos/username/repository/commits
More on that: Other Authentication Methods

Assuming you did the work from your local Git project, then GitHub does not have to be involved at all here. You can checkout the branch in question, fetch update it, and then use git log:
git checkout master # assuming contributions go to the master branch
git pull origin master
git log --author="yaylitzis" # replace 'yaylitzis' with your actual username
The pull is required because perhaps your local branch does not have all your commits for some reason.

Related

After a github fork, how can I compare my branch to a branch in the upstream repo?

I was trying to compare changes I made to a forked repo.
To make this real, here is the example:
I forked https://github.com/springframeworkguru/sfg-di as https://github.com/steranka/udemy-sfg-di.
I got a local copy of the (forked) repo git clone git#github.com:steranka/udemy-sfg-di.git
I changed to the branch I wanted to work on git checkout property-source.
Made changes and committed the changes (to my local repo).
Push my changes to my fork so the changes can be compared to the original repo. git push
Now I want to compare my changes to the equivalent branch on the original repo.
The origin and upstream are set to:
origin: git#github.com:steranka/udemy-sfg-di.git
upstream: git#github.com:springframeworkguru/sfg-di.git
Searching for solution
My searches indicated that there was not a built in way to do this using the git CLI, nor the github website.
What I did find was:
https://stackoverflow.com/a/66613981/3281336. Basically do the compares via local repo.
How to compare a local Git branch with its remote branch - How to compare local vs remote branch. Later, I learned this is basically what a forked repo is... Just another remote.
General info about forks (from GitHub.com) https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-comparing-branches-in-pull-requests - The GitHub.com docs indicate that this is doable if you create a pull request. This is not what I want to do.
My question
How do you do this? I ran across gh-cli which might do it.
Can this be done via the github.com web interface? If so, how?
Append /compare to the URL of your repo. Example (try it):
https://github.com/mattneub/amperfy/compare
That's a public fork of a public upstream. You can select two branches, possibly at the two different repos, to see the diff.
I've selected the answer from Matt because that is the answer I was looking for. But another possible solution is based on #torek's answer.
The solution is to pull the upstream repo's branch that you want to compare locally and then do normal git diff commands. The result is that the compares are done via my local repo.
The steps to do this are:
Setup the pointers to the upstream (the repo you forked)
Get the upstream source and put it into your local repo
Compare the upstream source's (local copy) to your code.
The code commands to do this are:
git remote add upstream git#github.com:springframeworkguru/sfg-di.git
git fetch upstream property-source
git diff upstream/property-source..
This turned out to be simpler than I expected.
One benefit of this approach over the GITHUB web ui is I could compare my code changes without pushing my code to the github.

What does it mean "to fetch" before I can push?

I uploaded my whole project on my repository of github yesterday.
I'd like to update the online version today, and when I use git push -u origin masterorder, the bash window says:
! [rejected] master -> master (fetch first)
So how do I "fetch"?
If I use git pull first, would my local files be overwritten by the online version?
So how do I "fetch"?
By using the command:
git fetch
Basically, your local repo is out of sync with the remote (Github) repository. If you have multiple remote repos, you can specify which one, and you can also specify which branch. Try
git help fetch
for a complete description of the command and the various parameters you can pass in.
If I use git pull first, would my local files be overwritten by the online version?
git pull is like doing a git fetch followed by git merge -- that is, it gets the updates from the remote and attempts to merge those into your local files. That may be fine, or not, depending on what you intend. Read the help for both commands so that you can make an informed decision.

Github - merging fork into master (locally)

So i have the following problem:
Back when i started programming, i FORKED a repository (using github for windows) for a browser-game. For some time now, i made stuff, did git commit and issued a pull request using the webpage.
The original author did authorize my pull request and my changes went live.
Recently, i have become an "official" author on the original repository.
So i dont want to work on my "fork" any longer but instead dev on the original.
Using github for windows, i decided to "clone" the original repo.
My github now shows my forked (AncientSion/FieryVoid) repository and the original (Aatu/FieryVoid).
Now what i would like to do is somehow "merge" my forked repo into my local clone of the original repo and from there commit to the master repo directly, that way deploying my local, not yet commited changes from my fork to the live version while at the same time getting rid of fork repository.
However, i have no idea if that works and if it does, how.
Can someone please advise ?
I don't think that the Github for Windows interface supports this, but this can definitely be done via the git bash console. This is untested, but the steps ought to be correct, since I've done something similar (identical, in fact) before. This assumes that your clone, AncientSion/FieryVoid, is up-to-date with Aatu/FieryVoid, which can be done with a pull followed by a merge, or, to avoid merge commits, with a git pull --rebase. So now you have AncientSion/FieryVoid and Aatu/FieryVoid, both present locally, with AncientSion/FieryVoid ahead of Aatu/FieryVoid by a few commits. What you need to do is pull in those commits into Aatu/FieryVoid by running the following:
cd path/to/local/clone/of/Aatu/FieryVoid
git remote add local_pull path/to/local/clone/of/AncientSion/FieryVoid
git pull local_pull master
git push origin master
Couple of assumptions:
You were working on the master branch of AncientSion/FieryVoid. If not, replace master in line 3 with your branch name.
origin is a remote that tracks the online repo Aatu/FieryVoid

Delete a closed pull request from GitHub

I accidentally made a wrong pull request and ended up closing the request myself. It's in a closed state right now but it's accessible via direct URL and showing on my activity bar.
Is there any way to delete a pull request completely so it's no longer accessible via URL or shows up on your activity history?
There is no way you can delete a pull request yourself -- you and the repo owner (and all users with push access to it) can close it, but it will remain in the log. This is part of the philosophy of not denying/hiding what happened during development.
However, if there are critical reasons for deleting it (this is mainly violation of Github Terms of Service), Github support staff will delete it for you.
Whether or not they are willing to delete your PR for you is something you can easily ask them, just drop them an email at support#github.com
UPDATE: Currently Github requires support requests to be created here: https://support.github.com/contact
5 step to do what you want if you made the pull request from a forked repository:
reopen the pull request
checkout to the branch which you made the pull request
reset commit to the last master commit(that means remove all you new code). Command: git reset --hard commit_hash_here
git push --force
delete your forked repository which made the pull request
And everything is done, good luck!
This is the reply I received from Github when I asked them to delete a pull request:
"Thanks for getting in touch! Pull requests can't be deleted through the UI at the moment and we'll only delete pull requests when they contain sensitive information like passwords or other credentials."
It's very easy actually:
You can empty it, that's the best you could do.
Go to your local
Copy your local branch unwanted-branch (against which the PR was opened) to a new branch new-branch. This copying is relevant if you want to back it up for any reason. Otherwise go to step 3.
$ git branch -b new-branch
$ git merge unwanted-branch
$ git push
Empty the unwanted-branch
$ git checkout unwanted-branch
$ git reset --hard HEAD~n #n is the number of commit the branch has
$ git push -f
Enjoy, your PR is empty and closed now ;). Go to remote and delete the unwanted-branch if it bothers you.

What does exactly fetch does in eclipse git (EGIT)?

In git documentation says fetch doesnt merge with your working tree. So lets say I have these branches: master, jhonny and miguel. Let's say master is for the last production code release.
--------------------------------------------master
\-----------------------miguel
\---------------------------jhonny
Miguel and I have tracking of all branches in our local repo. Lets say Miguel commit and push his brach to the github repo. I want to have the miguel push localy. If I do fetch, what will happen? Does fetch just updates the remote repo reference? Origin in this case.
Vote down if you think this is duplicated. But I couldnt find the answer Im looking for yet.
Regards.
Yes, git fetch only updates the local copy of the remote repo (i.e. the remote reference) - it doesn't then merge those updates into the local branch the way git pull does.
In this sense, git fetch is quite 'safe' as there are no merge issues and all of your local branches remain untouched. For a more detailed discussion, see: What is the difference between 'git pull' and 'git fetch'?
If after a git fetch you do want to merge the remote changes with the local branch, you then need to run a git merge. This is in effect what git pull does.