Pushing project to Bitbucket with Egit deletes previous push - bitbucket

When I use Egit to push something to a team in Bitbucket (we are all admins), the previous post from any member is deleted. The same thing happens with the other members if they push something too.
I use this configurations:
Everything works well but this, there's any idea to solve this?

Why do you have "Force Update" checked?
Normally (when "Force Update" is not configured), in a situation where you would discard other people's changes, the server rejects the push with a "Non fast-forward" message. In that case you have to first merge the remote changes into your local branch, and then push again. With this, the other changes are preserved.
But when you have "Force Update" checked and push a branch, what happens is that the branch on the remote repository is updated to point to the same commit that it pointed to on your local branch. That happens even when your branch is behind or has diverged from the remote branch, causing it to effectively overwrite/discard the other people's commits.
So what you want is to disable "Force Update" for refs/heads/* (head is another word for branch). See also Note about fast-forwards in the help for git push.
As a note: In some server software it's possible to configure the repository so that such "non fast-forward pushes" are denied (regardless of the force flag of the client). But that doesn't seem to be supported by Bitbucket yet, see this issue.

Related

Option to disable force push with active Bitbucket PRs

I am looking for a possible solution not to let a PR merge if there is a force push to the source branch.
Is it possible to disable force push to a specific branch type(say feature/) once a PR is raised with the same branch as the source or target?
Or the other way around, is it possible for PR not to accept changes based on force pushed?
As force push to PRs remove review history and makes hard to track and review. It would be nice to have one of the above options workings

Gitbash/bitbucket: how to push changes from previous push, overwriting a "bad" push

I have a project I have been working on, and I was suggested to use Gitbash and Bitbucket to keep track of all the changes I will make.
I made some changes, pushed them to my bitbucket, and then cloned it to really make sure I was working on the latest files. Made a few more changes on that cloned download, tried to run it on my hardware and it wouldn't run. Couldn't figure out why either.
I went back to the previous download and managed to get it running on my hardware setup. I have made a multitude of changes since but just completely forgot to push.
Now, when I try to push, because there are files I don't have locally, I get the error:
On branch master
Your branch and 'origin/master' have diverged, and you have 2 and 5 different commits respectively.
It also tells me to git pull to merge the remote to my local files.
I do not want to do that, as that would overwrite changes I want to keep locally. I just want to push what I have locally, to my remote.
I am not a software engineer at all. All of the helps pages and tutorials are going way over my head.

How to overwrite my all local changes in XCode repo when I see "Rebase local changes onto upstream changes" message?

I have a Bitbucket repo where the most recent changes are pushed by another developer teammate. His push is more important and I want to make sure my local is same as the latest in the repo. I have not made any changes but still Xcode shows me this warning. I am fine is all my local is overwritten. How do I do it? Should I check the box when I am pulling changes in Xcode from the BitBucket repo? Or do I need to do a git pull from terminal?
If you want to merge another branch into yours, you should always commit your changes first. When conflicts emerge, you just solve them and there you go, you are on the latest commit with your changes preserved.
If, however, you prefer rebase instead of merge - you HAVE to commit your uncommited changes first, then you can rebase on the latest commit from the other developer's branch, the nice thing about rebase is that it keeps the git history cleaner while also leading you trough the conflict solving, because it basically tries to put each commit of yours on top of the commit that you are rebasing onto, so it sort of "guides" you trough resolving conflicts as you have small chunks of code to resolve and then continue rebase.
Try to read more on this. This article summarises the difference between merge and rebase:
https://www.freecodecamp.org/news/an-introduction-to-git-merge-and-rebase-what-they-are-and-how-to-use-them-131b863785f/

How to relaunch GitHub check without pushing new commits?

I'm currently using GitHub with a basic Jenkins integration (with the GitHub plugin): each time I push something, my Jenkins tests are triggered and the status is reported to GitHub.
For some dirty reasons (and I know the root cause is here), my tests could randomly fail and then report a failed status to GitHub (which blocked the possibility to merge the PR: and that's the expected behavior).
Do you know if it's possible to relaunch the tests without pushing a new commit? Because I know if I relaunch the tests, they will pass.
Update: you can also push an empty commit to your branch to re-trigger status checks: git commit -m "retrigger checks" --allow-empty and then git push <branchname>
You can do this by closing and then re-opening the Pull Request. This will cause all status checks to run again on the same commit.
Doing git commit --amend and force pushing makes github retrigger all checks. Not perfect but better than closing then reopening the PR.
There's now a button in the Github UI to rerun checks. Not sure if it works for Jenkins, but it worked for my situation.
If you open a PR that failed, under Checks tab you will see the list of all checks that were performed on your PR. Next to the failed ones, there will be a clickable text that says "Re-run"
Depending on how you have integrated Github with Jenkins and what plugin you have have used, the method might vary. But usually you have support for "magic"-sentences that will retrigger Jenkins if added as a comment on Github.
For example commenting "test this please" or "retest this please" in Github might retrigger Jenkins.
Seems like closing and re-opening the PR could be an option.

What Discard all changes in Xcode source control actually does?

As in question, I wonder if there is some documentation about what this Xcode command does (Source Control -> Discard all changes) ?
I guess it reverts to last commit but on local branch ? Can somebody confirm that it doesn't affect the same remote branch automatically ?
I didn't use git in XCode, but I can be so sure that Discard all changes will NOT affect history in the remote.
It will most probably discard all unstaged changes you made to the tracked files in the working directory, simply like executing git checkout -- . from the terminal.
With unstaged, it means changes you once executed git add -u for will not be discarded.
By the way, to find out what it actually does, a test by yourself is needed.
I ran into a similar problem in which I wanted to roll back to my most recent local commit, and being unfamiliar with command line git, I took a chance with selecting 'Discard Changes in /filename/' and it did exactly the same thing all the websites said git checkout would do.
Once again, this is just my "test" but the feature works as advertised.

Resources