How can I view the differences between commits filtered by contributors on GitHub? - github

I'm not sure if GitHub questions are off-topic, but I'll take the chance.
Day 1 - I created a new branch called feature and added changes.
Day 2 - I ran git pull origin master
Day 3 - I created a PR and I merged to master
Day 4 - I continued working on branch feature and again, I added some changes.
Day 5 - ... and so on...
While I wrote the code, another contributor wrote with me on the same branch (feature)).
I and another contributor wanted to review our work from the first commit to last. In order to do so, I navigated to:
https://github.com/<organization>/<repo>/compare/<base>...<target>
base = our initial commit
target = our last commit
Well, it didn't go quite as planned. We noticed that a lot of the changes were not made by us, but by different contributors (11 in fact):
I get that it happened because a lot of commits that weren't written by us has been made between base...target. So I want to know, is there a way I can filter the commits by specific contributors? or, is there any other way we could see only our changes?

For
You can filter, if your github repo is
https://github.com/name/repo/
you can filter by author on a specific branch
https://github.com/name/repo/commits/feature?author=john.doe
A real example:
https://github.com/utix/util-linux/commits/cal_column?author=karelzak
https://github.com/utix/util-linux/commits/cal_column

Click on "Commits 97" (on your picture) and you will see all commits from this GitHub project. You can also see all users who have ever changed your project. If you then click on a user name, all commits of this user are displayed in this project. So you can click on your username and the other contributor's username, and you'll see all the commits from the selected user both times.
I hope you come out with my explanation

Related

How does squashing, rebasing, reset --soft affect github contributions page?

For some projects I do or work on sometimes it is usually best that we squash/rebase all changes into a single commit. However, I was wondering how this affects the contributions page on github.
For example, if I spent 2 months pushing changes to a project I created and then after 2 months decided to rebase it to one single commit, would github remove all the contribution cubes on the map for the past two months?
I saw this still here so I figured I might as well answer the question. So the answer is YES. It will remove the contributions from the graph. It won't do it right away because commits that are no longer being pointed to by anything can technically still be reached for awhile but are eventually garbage collected and thus removed from your contributions page.
The reference page is "Why are my contributions not showing up on my profile?"
Commits will appear on your contributions graph if they meet all of the following conditions:
The email address used for the commits is associated with your GitHub account.
The commits were made in a standalone repository, not a fork.
The commits were made:
In the repository's default branch (usually master)
So if your rebase affect commits in master, chances are your contribution page would reflect that.

Eclipse Git - Making changes at the same time

This is probably a noob question, as I only started using Eclipse Git a few days ago.
I was wondering if it was, in any way, possible to have multiple people working on different files in a repository but, when ready to commit, only have one commit for all, instead of one commit per person...?
I was also wondering if there was an option to automatically pull modified files, or a way to update the modified files in every person working in the repository, without making a commit per person first?
I'm asking this because I use Jenkins, and every time a commit is made in GitHub, it immediately starts a build, and it would be very annoying to create a commit per person just because of probably some lines of codes.
Best regards
EGit doesn't have a feature for that, but you can work around it by "squashing" the commits in GitHub. Here's how it works:
Step 1) Create a branch
Step 2) Make everyone work on that branch until it's time to commit (in your words)
Step 3) Create a pull request for merging the branch with master or whatever branch that is marked as default
Step 4) Click "Merge pull request" and then do this:
If you can't find the option to squash-merge, go to the repository settings and make sure the checkbox highlighted in this image is full:
Step 5) Confirm squash and merge

How do I pull a specific version of a branch to the master?

This question pertains to my workflow using github. My colleague sent me a pull request and kept advancing the branch he was working in with new commits? I want to pull the commits related to the pull request, but the pull request now has the commits too. I searched for solutions and kept being led to the "rebase" command. Regrettably, that command is too complicated for me, plus I use tortoiseSVN as my interface to github. I had some solutions using revert, but they were all un-elegant and there had to be something easy. Also the last time I tried a revert, I had some conflicts with commits that no longer existed because of the revert.
My colleague got a response from a github "ask a human". I am reporting the solution here to help other users.
Navigate to the branch with the work to be pulled.
Navigate to the commit history for the branch and identify the point in that history that you want to pull into the master.
Click on the button on the right marked "<>" == "Browse the repository at this point in the history".
Click on the branch pull down menu and create a new branch. This will create a new branch at that point in the history that you want to pull into the master.
Create and execute a pull request to merge that branch into the master.
Too easy. I don't understand how I didn't run across an example of this workflow. I hope I save someone else the time and headaches that I spent.

In GitHub, is there a way to see all (recent) commits on all branches?

In GitHub, is there a way to see all recent commits on all branches. It would be best in reverse chronological order.
Maybe I'm snoopy, but I'd like to be able to see what my developers have been up to recently, at least in terms of commits to the repository on github. So far the closest I've seen is the network graph, which is certainly very useful.
Please note: this is not the right answer, although I hope it continues to be useful. NB it has been made a "Community" answer so I don't receive any points from upvotes
To see all commits for a specific branch (so this does NOT actually answer the original question, which is to see commits across all branches):
Click "Code" (left-most tab) on the main page for the repository. Under those 4 buttons ("master", "Go to file", "Add file", "Code") there is a blue rectangle. At the right end of that is a clock icon and a number. If the viewport of your browser is wide enough it even includes (hurrah) the word "commits". This is a link. Click and ENJOY!!!
NB the URL for this page is like this: https://github.com/myProfile/myRepo/commits/master
This is an old feature of GitHub but not really that intuitive.
Using the GitHub website:
Click a project
Click the 'Insights' tab (moved inside the Meatballs menu)
Click 'Network'
Click on the 'node/circle' for each commit to go to that commit.
Diagram below.
Additionally, you can drag to the left to see all commits throughout time for all forks and branches.
I guess there is no any button which shows you a complete list of commits. If you want to list all commits in a repo, you could browse the following URL:
https://github.com/username/repository/commits
You can view the list of commits by adding the word commits (in plural) at the end of repo URL .
Optionally, you could add some query string to narrow the results in the list. For example:
https://github.com/username/repository/commits?author=johndoe
Update
Thanks to #lii I update this post:
If you want to view all commits in a branch, browse the following URL:
https://github.com/username/repository/commits/branch-name
And you could narrow the list of commits by browsing the following URL:
https://github.com/username/repository/commits/branch-name?author=johndoe
The user interface in GitHub does not currently support a way to see your commits in a branch from the code tab. However, I observed that when I select a branch from the branch selector dropdown, I see the following URL:
// This shows me all commits from all users in the branch called "2.2-stable"
https://github.com/jquery/jquery/commits/2.2-stable
If I click on a username in the list of commits, I observe the following URL:
//This shows me the list of commits from the user "mgol" in the master branch (default branch)
https://github.com/jquery/jquery/commits?author=mgol
So, I thought to myself, why not try to add the query string ?author=mgol to the URL that showed commits on a specific branch:
Solution:
// Show me the list of commits from the user "mgol" on the branch called "2.2-stable"
https://github.com/jquery/jquery/commits/2.2-stable?author=mgol
Again, the user interface has no button that lets you see this view (to the best of my knowledge) but you can manipulate the query string to filter only what you want to see.
Since the 'Insights'/'Network' solution is only available for public/GitHub Team repositories, I found a method that works for both private and public repositories.
github.com/username/reponame/branches
Next to the currently selected branch dropdown, there is a link to github.com/username/reponame/branches
This gives you a (clickable) list of all branches with their most recent commits, in chronological order, as asked in the question:
Although this method does not show all commits (only the most recent one) across all branches, this does allow you to check which of the (new) branches has been updated most recently, and further your investigation. I use this all the time.
Look here: Github API: Retrieve all commits for all branches for a repo this is the only options.
On website you can see only branch specific commits - you need to manually switch between them.
Bitbucket allows to see all commits on all branches.
If viewing this from github.com is not a hard requirement, you can use git:
Clone the project locally, then run the following to show the list of all commits from all branches, sorted by date in descending order:
git log --oneline --all --since="Jan 20 2022"
where --since (and --until) allows you to specify a time range and --all displays commits from every branch including remotes. Alternatively you can replace --all with --branches=*.
You can also display the date and authors with something like this:
git log --oneline --pretty="%C(yellow)%h %C(cyan)%cd %C(magenta)%aN%C(auto)%d %Creset%s" --date-order --date=format:"%y%m%d-%H%M" --all --since="Jan 20 2022"
You can also add --graph switch to get a more structured view instead of a plain list.
Please note: dates may not be reliable to track work: some operations will modify history, e.g. a rebase may update the date of old commits to the date of the rebase, squash may keep the oldest date only, a commit date may be modified arbitrarily, etc.
There is no way to attain that within the original GitHub. But there is a work around.
You could use Le Git Graph (read as legit graph), a browser extension that does exactly this.
Install the extension from here : https://chrome.google.com/webstore/detail/le-git-graph-commits-grap/joggkdfebigddmaagckekihhfncdobff
It will add a new "commits" section to every GitHub repo you open. Open the commits graph and there, all commits across branches will be listed along with the git graph.
Hope it helps!
An upvote would be highly appreciated!
The actions tab has all recent activities done on a repo for all branches.
The way I have my repos setup, each developer has a user.git account. I recommend doing the following:
git fetch --all
This fetch updates all the local copies of remote branches but doesn't create new local branches of these tracking remote branches. If you have local branches of all your developer's branches, you will want to run:
git pull --all
So what you need to do is git fetch --all and then git pull --all. I hope this helps.
Lastly, you can also do git remote update which is the same as git fetch --all
best way to access all commit of a repository is
install app of the GitHub on your PCs
clone repo with that
on the history tab you can find all commit
but you need patient and scroll down on this tab ;)
have a good time
Simply run the following command and keep on pressing enter as you see the details of each commit step by step
git log

Github repo squash commits on master

I'm working with a github repo where a lot of commits historically have been "bugfix", "bugfix for real this time", "ok final bugfix", "finally fixed".
These were committed directly to master. How can I squash them?
Fromt his post a year ago - it basically sounds like this is bad, want to squash multiple commits in github. Has anything changed in the past year?
The answer today is basically the same: Squashing these commits is possible, but rewriting shared history is something to be strongly avoided in Git.
Imagine that you and I each have a copy of some repository that also exists on GitHub:
A---B---C
You notice that commits B and C should really have been committed together, so you squash these commits in your local copy. You now have
A---D
where D is a combination of B and C, while GitHub and I still have
A---B---C
At this point, even though the file content is the same everywhere, our commit IDs have diverged. Now you can't push to GitHub without --force, because GitHub's master branch contains two commits that are no longer present in your history.
If you do use --force you can make GitHub accept your changes, but now my repository contains commit objects that are no longer present upstream. I can't push to GitHub without using --force (which will invalidate your changes) or without doing a relatively funky merge to bring your changes in, probably rebasing my work, etc. And that's only possible if you communicate with me outside of Git to tell me what you've done.
This gets even messier with more developers (imaging doing this on the Linux kernel repository!) and with more work being done concurrently.
Really, any time you're tempted to git push --force, sit back and think for a moment. You're probably doing something that should only be done with an extremely good reason.
My recommendation is to accept that your history is a bit messy, but to try to improve things going forward. These commits can be cleaned up locally, before you push to GitHub (or share with other developers). Work in feature branches, use cherry-pick, rebase, etc. to clean up the commit history if necessary, then push.
Squashing is something which is used to merge a lot of commits into one. If you want to clean up last serval commit's check your last git log's by using
git log
this will look something like this
* df71a27 - (HEAD feature_x) Updated CSS for new elements (4 minutes ago)
* ba9dd9a - Added new elements to page design (15 minutes ago)
* f392171 - Added new feature X (1 day ago)
* d7322aa - (origin/feature_x) Proof of concept for feature X (3 days ago)
now if you want to squash last three commit's then
git rebase -i HEAD~3
by doing this you'll get into editor like this
pick f392171 Added new feature X
pick ba9dd9a Added new elements to page design
pick df71a27 Updated CSS for new elements
Edit the one who you want to squash like this
pick f392171 Added new feature X
squash ba9dd9a Added new elements to page design
squash df71a27 Updated CSS for new elements
When done, save and quit your editor. Git will now squash the commits into one. All done!