How to get the commits of a branch which is NOT a default branch of a repo? - rest

How to get the commits of branch which are not default?
Currently the search commit api is giving only the commits present on default branch.
I have tried the below things. By adding branch name as a query param but not getting anything.
If I remove that query param I get only default branch (i.e. main) commits.
TRIED This: but not getting any output.
https://api.github.com/search/commits?q=repo:test-dai/issue-test+committer-date:1970-01-01..2023-02-14&branch=demo
https://api.github.com/search/commits?q=repo:test-dai/issue-test+committer-date:1970-01-01..2023-02-14+branch=demo
I want commits of a branch which is NOT a default branch.

You will need to send a request to the /repos/{owner}/{repo}/commits/{branch_name} endpoint. It is a linked list, so you will first see the head.
This question dealt with your problem on GitHub.

Related

When I work on my branch, my pushes aren't showing up on GitHub

When I work on my branch, my pushes don't show up on GitHub, so the pushes don't turn GitHub progress graph boxes green. When I work in the main branch, everything is fine. Could somebody please help me?
You need to merge your branch with the main branch. Or push both branches to github and make a pull request and merge the branches on github.
To push all your branches to github:
git push -u --all
now all your branches should appear
After you pushed all your branches you can use a pull request to merge the 2 branches.
Cick on New pull request.
From the dropdowns select the branches you want to merge. And then click create pull request. A message box will appear. Write the commit message you want and click again Create pull Request.
After you have created the pull request
If you have no code conflicts. You should see the picture above. If there are code conflicts you need to either resolve them in your IDE or via the command line.
If you want to merge branches without pushing to github here is a useful link.
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Getting rid of commit after completing Pull Request in GitHub repository

I'm trying to create a Pull Request in GitHub repository from one branch to another branch. On completing the Pull Request, I see 2 commits being added:
Is there a way to get rid of the commit "Merge pull request from ..." via settings?
In ADO repository, there is an option to "Rebase and fast-forward" to get rid of that commit. Is there something similar in GitHub?
Thank you!
When merging a pull request on GitHub, you have 3 options when you click on the drop down button beside the button to merge the PR:
Create a merge commit
Squash and merge
Rebase and merge
While the first one is selected by default, you can choose the 2nd or 3rd option in case you want to avoid the merge commit as mentioned in your question.
All the 3 options are also explained in detail in this GitHub documentation.

How to get all commits from all branches via bitbucket REST api 1.0?

I want to get all commit data from all branches via Bitbucket REST api 1.0 like this :
curl -u $id:$password http://$path/rest/api/1.0/projects/$project/repos/$slug/commits
All I get is all commit data from a default branch only, not all branches.
What I want is like this :
curl -u $id:$password http://$path/rest/api/1.0/projects/$project/repos/$slug/commits?branches=all
Of course, it doesn't work. :/
I've already read the official document but I cannot find a clue.
https://docs.atlassian.com/bitbucket-server/rest/6.10.1/bitbucket-rest.html#idp205
I guess, getting all branch list, and then searching all commits at each branch can be possible. It seems annoying because I have 200 projects and almost 4,000 repositories.
I need your help.
Thank you.
I found out there is currently no single endpoint to return all the commits associated with all branches.
There was a suggestion few years ago but it was rejected by the developers.
https://jira.atlassian.com/browse/BSERV-5363
The only way to get all commits across all branches is :
Make an api call for all the /branches
For each branch make an api call for its /commits?until=
Remove duplicate commits, then insert the branch commits by timestamp.

How do I make my pull request only show the changes since my last pull request on github?

How do I go about making my pull requests have only the changes made on the new branch? Every time I push a branch it has all the changes from the previous branches included in the pull request also.
My manager is really big on making sure we do small PRs and have only the new changes on each one for easy review, but I'm at a complete loss as to how to do this. This is my first dev job and up until now I unfortunately haven't been able to do group work so managing PRs that might be a while before they are merged in is totally new to me.
So far I've only found how to cherry pick commits, is this the only way?
If I understand you right, you have a main branch (master?) that contains the latest version of your software and you have one or more other branches that contain modifications. You do some more modifications in that other branch and if you create a pull request it will contain all other changes.
The most simple solution I can think of is to use dedicated branches for all changes. Before starting to work, create a new branch from the main branch with the ticket ID, work description or whatever you use to describe your work: git branch -b feature-123.
Commit to this branch only and push it to the repo. If you now create a pull request from this feature branch to the main branch, it will only contain the changes you did and nothing else.
The further pull requests highly depend on your internal workflow and branch structure. But basically this workflow applies to all new changes.

see what pull requests depend on my branch (github)

I recently merged a branch into master and want to delete it now that I'm done with it. But github tells me that I can't delete it because some open pull request depends on it. How do I find out which pull requests depend on this branch?
To find the open pull requests which depend on a particular branch called foo (i.e. pull requests for merging other branches into branch foo), use the following Filter query in the Pull requests tab:
is:pr base:foo is:open
This will identify the Pull Requests preventing the deletion of branch foo
I found that one of my open pull requests was trying to merge into the branch I was trying to delete, instead of merging into master as it was supposed to. Fixing this allowed me to delete my branch.
I could not find a way to easily view all the open pull requests involving any given branch, so I had to go through my open PRs one by one.