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

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.

Related

Commit does not enter the contribution graph

I recently made several commits, but they are not being counted, they all follow the patterns they were giving in the past, but recently they are simply not going to the chart anymore, could you help me?
Was there any update that removed this benefit from free users?
https://github.com/Peedrooo
In order for a commit to be counted in the contribution graph, it must have been merged into the default branch in the main repository. Commits in forks or in branches other than the default branch don't count.
Additionally, if it's in a private repository, you must enable the option for those to appear in your profile.
GitHub provides documentation on how to troubleshoot this.

How can I view the differences between commits filtered by contributors on 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

Deleting a merge from History Git

I'm trying to figure out how to fix a merge problem me and my team are facing. I'm working on this project at school, and my team has made a lot of progress, but one of the team members who didn't know what he was doing force merges his code into the master branch. His branch is like 2 days old and we've already implemented a lot of new functionality since time, his branch is probably 20 or so commits away from head. I've tried rolling back to a stable master branch but his branch is intermingled with the stable so I can't seem to retrieve the stable back. Any suggestions? we are fairly new to git, but that person had no idea what was going on and just force merged his code without resolving the commits.
Go and sit on his computer.
Type git reflog, it will show you the full commit history (as well as other things). Find out the last good commit id , check it out git checkout SHA-1. create branch at this point and commit it back again. Once you are on the right commit your repository will "get back" to the last good place.
Another option is to perform a git bisect and to find out what is the bad commit.
Click here for blog about reflog
Click here for blog about bisect
Good luck.

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!

GitHub: restore old commits

I am working with the GitHub GUI on Windows.
I did some work on my project which was successfully committed about a month ago going forward. Unfortunately other person who also works on this project recently committed the files I changed without realizing that he removed a huge portion of my work.
Now my question would be: is there an easy way of restoring my commits. This is not one commit. For the past month I made several very important commits to the project which got killed by the other party error.
I really don't want to go thru each file individually and re-aaply the changes manually, especially since I already got paid for that work.
How can I get my commits back?
IF you don't see your commit anymore in the history of the repo, that would mean the other developer has done a forced push (git push --force).
In that case, use git reflog (as in this answer) to find your commits back.
If yo do see your commits, then you could revert (git revert) the commits introduced by the other developers in order to cancel them, which should leave your branch in a state reflecting your work.
In both cases, this is a communication issue: you need to coordinate with the other developer in order for both of you to agree on a state from which to move forward.