Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Checkout and merge into another git branch

TylerAvocat
Contributor
October 9, 2018

I setup a manual step to merge the branch "master" into the branch "rc".

script:

    - git fetch

    - git checkout rc

    - git config

    - git rebase master

    - git push

I get "error: pathspec 'rc' did not match any file(s) known to git." but I am sure the branch is there.

I know that Pipeline only checkout the triggering branch at the beginning of a step: git clone --branch="master"

Could that prevent from accessing other branches ?

 

2 answers

2 votes
davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2018

Hi @TylerAvocat

You can configure your fetch by adding this to your configuration before the fetch command

- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

As a side note you can check what exists via

- git show-ref

 Hope this helps

Ilan Hazan July 31, 2019

The full commands to do the merge are:

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git checkout master
git merge --no-ff --no-edit develop
git push
git push --tags

See full BitBucket's Pipeline script for merging branches 

Like Felipe likes this
0 votes
harsh-mrikal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2024

I'm encountering an error:

```
error: pathspec 'feature/example/auto-merge' did not match any file(s) known to git.
```

Below is my script:

- `git config --global user.email "example@example.com"`
- `git config --global user.name "example"`
- `git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`
- `git checkout feature/example/auto-merge`
- `git merge origin/feature/example/auto-merge-stage --no-ff -m "Merged stage into dev2"`
- `git push origin feature/example/auto-merge`

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events