damian
damian

Reputation: 4044

Intellij GIT - Push to branch all changes since clone

I cloned a project and I've been pushing my changes to a branch. Now I want to push all the changes since the clone (not only the last commit) to a new branch I'll create; but when I go to VCS->GIT->Push in the right panel I see that only the changes made since the last push are selected. How can I tell intellij to push all changes since the clone?

Upvotes: 0

Views: 259

Answers (2)

Dmitrii Smirnov
Dmitrii Smirnov

Reputation: 7528

The push dialog show only commits that are not present in the remote repository. Effectively, that is only your last commit.

Any branch you create on the remote from your current HEAD will contain all the commits you did since clone anyway.

Upvotes: 1

Javaru
Javaru

Reputation: 31936

VCS > Git > Push will show all un-pushed changes. It will not show pushed changes, even ones pushed to/on another branch. To view all commits (regardless of their being pushed or not) you can:

  1. Go to the Version Control tool window and
  2. then to the Log tab.
  3. You can filter the view to show only commits to a articular view.

enter image description here

Now I want to push all the changes since the clone (not only the last commit) to a new branch I'll create

You'll need to merge the changes from the original branch to the new branch. You can do this in two ways.

Option 1 - merge the entire branch

Switch to the target branch (the new branch you want to merge the changes to). In the bottom right of the IntelliJ IDEA window, open the VCS dialog by clicking the double arrows:

enter image description here

In the popup, select {source branch} > merge. For example, here I'm merging from "my-work-branch" branch to "the-target-branch" branch:

enter image description here

You should then get a confirmation of the merge.

enter image description here

All changes made on the source branch will not be merged onto the target branch. You can then push those.

Option 2 - Cherry Picking

Switch to the target branch (the new branch you want to merge the changes to). From the Log tab of the Version Control tool window (see above), select the individual commits form the source branch you want to merge to the new branch. (Hold down the Ctrl key to select multiple commits, or the Shift key to select a consecutive group). Click the cherry pick button enter image description here from the Version Control tool bar (or right click and select it from the context menu).

Upvotes: 1

Related Questions