Eclipse EGit Automerge commits to master to other branches - eclipse

I'm working since a half year with Egit and Github, and it works quite well. My workflow works with many different Branches, where every new feature or Bugfix is a new branch which will be merged into the master branch when finished. My question is, is it possible to apply the changes in the master branch to all other active branches. Thanks.

Have you tried:
1) Switching to the branch in your local eclipse (right click project name -> Team -> switch to -> your branch)
2) Then doing a fetch from upstream (Team -> Fetch from upstream)
3) Then doing a merge from master (Team -> Merge -> click origin/ master)
This will merge all changes from master into your current checked out branch. Then you can just commit and push. Ultimately you can also replace steps 2 & 3 with a pull (Team -> Pull) as well if it is configured. I am not sure if there is an easier way, but you would do this for each branch you want updated.

Related

Eclipse Git - switch branch without merge

This is maybe a dumb question, but I could not find a way to solve my problem. I am working with Eclipse and Git.
When switching and pulling branches to work on different features, the local commits of the previous branch are added to the commit history of the new branch.
Let say I am working on a branch A, commit twice, then I create from master a branch B, switch to this branch B, pull, and perform one commit. Now my branch B contains the changes made on branch A + the commit made on branch B, making it difficult to create a pull request to merge the change of the only commit B to master.
I would like my local commits/changes to be erased when switching to another branch. How can I do that with Eclipse Git?
After playing around with eclipse, I noticed there was two possible pull actions:
The default one does Fetch + merge, resulting in the mess described in the question
The other option allow you to select Fetch + rebase, to rebase your working directory to the state of the remote branch.
Based on this answer https://stackoverflow.com/a/17324792/10631518 you can even make rebase the default behaviour by running
git config branch.autosetuprebase always

switching to branch in Eclipse created from atlassian jira

I have created a branch from atlassian jira and I can see the branch in the sourcetree, under branches. But when I am going to Eclipse -> Team -> Switch to -> Other -> Remote Tracking I can't see it anywhere.
When I also go to the command line and type
git branch -a
I don't see it
Did you make sure you fetched from remote after having created the new branch in JIRA?
If not, it would explain the remote branch not showing up in your branch -a log.
In that case, just git fetch and your local refs of remote branches will be updated.
(And then you'll be able to git checkout <your_new_branch> to create the local counterpart and set its upstream in one go)

Within Eclipse, switch from using the Master branch in the Local Repository to something else

I created an empty project in Git. I also created a Java EE projcet in Eclipse (note: Eclipse has the Git plug-in installed).
From within Eclipse, I accessed and duplicated the (empty) Git Repository project on my Local Machine (or rather laptop).
I then wrote some code in my Java EE project.
From within the project, I then used the Team -> Commit option on it to :
1) Add the project to the Local Repository
2) Commit and push the contents from the Local Repository to the Git Repository.
My problem is that all of this work was done using the Master branch.
The Git Repository is currently sitting on the Master branch.
The Local Repository is currently sitting on the Master branch.
Whenever I make changes to the project and do a Team-> Commit, all actions happen with the Master branches.
Master -> Master
What I would like to do is as follows:
1) create 3 more branches in Git Repository (called consolidation, testing, production) - each new branch would be a copy of the Master Branch
2) On the Eclipse side, I need to fix it so that when any changes are made and saved to the Local Repository, the data will be saved to the
Consolidation Branch of the Local Repository and ~NOT~ the Master Branch (which is what happens now).
3) After saving data in the Consolidation Branch, from then on out, when code is sent to the Git Repository, it would be done by using the Consolidation branch and NOT the Master branch.
How can I do this?
TIA
Update
#Howlger
Hi and thanks for the response! Your suggestion gave me a clue on how to solve the problem. First, I logged into Git and copied the Master branch to a "dev" branch.
Next, I switched to the Git perspective (locally) under Eclipse and created a "dev" branch for my project:
Branches -> Switch To -> New Branches
Then, I followed some of your advice except I created a path that would allow for
branch : dev (local) => branch : dev (remote)
It is under the "Advanced" button.
I did a small test and it worked. Thanks again!
Update
Hi again - just logging in to note that I changed the references so that
Source Ref = refs/heads/*
Target Ref = refs/heads/*
The mapping of a local branch to a branch of the remote/upstream repository is specified by the push ref mappings. It looks like your current push ref mapping is HEAD:refs/heads/master: your current local branch will be pushed to the remote/upstream repository master branch. To map local branches to the remote/upstream repository branches with the same name, just remove all push ref mappings:
In the Git Repositories view righ-click the Remotes > origin > push node and choose Configure Push...
Select the mapping and click Delete
Click Save
See EGit User Guide > Push Ref Specifications for more details.

VS 2017 Team Explorer GIT "Push Branch" Grayed out

VS 2017 Team Explorer GIT "Push Branch" is Grayed out for me. I create a new local branch from a remote branch with no tracking and then I try to create a remote branch with the same name as the local branch by clicking on "Push Branch". Why would this option be grayed out for me?
I place it here, as someone like me will search again for that, I have resolved by doing branch Rebase. Commit your changes before. And then:
Probably it happens after you have manipulated remote repository settings.
In another case i just deleted all origins and created them again
Another addition. Be sure that you always has remote with "origin" name, that's another problem I faced right now, during migration of my projects.
Rename one of your remotes to "origin" with this command:
git remote rename your-remote-name-goes-here origin
Then you should be able to Push, Pull, and Fetch in Visual Studio. These options will no longer be grayed out.
The direct way to push a new created local branch to VSTS git repo by VS is clicking push branch button directly on local branch (don’t need to create the same branch in remote manually).
Detail steps as: VS -> Team explorer -> Branches -> right click the local branch -> Push branch -> then the local branch is pushed to remote.
Since you have already created the same branch on remote, you can fetch first and then push:
Team explorer ->Sync -> Fetch -> push.
when you clone the remote repo (no matter on VSTS or bitbucket) again, and siwtch to the new created branch, the branch willexist in remotes/origin, so you can push directly.

How do "reuse" a branch on Bitbucket / Sourcetree after merge

I was working on a branch of my Bitbucket repo (lets call it "frontend-dev"), which has now been merged with the master branch. I would like to branch again to make further changes, without creating a new branch. How do I branch and get back onto "frontend-dev".
I am using Sourcetree to manage version control.
Normally merging to master does not close or delete the branch. If there are changes in master since the merge from "frontend-dev", you can merge back to "frontend-dev". Either way, you can then simply switch your working copy to "frontend-dev" and continue developing.
Another question discusses what to do when you have closed or deleted the branch: Restore Merged Branch in Bitbucket Repo