user2997418
user2997418

Reputation: 658

applying a workflow of commit from DEV branch to STAGING branch

I am new in git and my question may sound easy to you, I was working on distant DEV branch, I pushed many commits, now I want to copy all these commit to STAGING branch. I am confused between merging or cherrypicking ... Below is the list of my local and remote branches, I checkedout to staging, then pulled from dev but didn't work. Maybe I am missing the correct name of the branches.

git checkout origin/staging 
git pull origin dev
git push origin HEAD

error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log. Automatic cleanup will not be performed until the file is removed.

warning: There are too many unreachable loose objects; run 'git prune' to remove them.

Already up-to-date.

enter image description here

Upvotes: 0

Views: 296

Answers (2)

Sajib Khan
Sajib Khan

Reputation: 24146

Just merge your DEV branch to STAGING branch.

$ git checkout STAGING
$ git pull origin DEV

$ git push origin HEAD      # push to remote STAGING

error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log

To solve the error Cleanup Unnecessary files and Optimized the local repository.

$ rm .git/gc.log
$ git gc
$ git fetch -p
$ git prune remote origin 

Upvotes: 1

smarber
smarber

Reputation: 5074

You can merge as @sajib khan said, but you should be aware that it may create a new commit if the two branches have diverged.

If you just need to get STAGING updated without saving the action of the merge, you should know that a rebase feature exists which will copy the commits from one branch to another without inventing new commits. This is most of time more convenient. However, since you're new to git, you should stick to the first option which is easier and does what you need.

By using cherry-pick, you ask git to "create" a new commit based on another commit's code. Which means it's literally a new commit since it's a different hash, creation date ... the only similarity between the created commit and the original commit is the code git-cherry-pick - Apply the changes introduced by some existing commits

Upvotes: 0

Related Questions