BitBucket - Add to develop branch directly instead of master

和自甴很熟 提交于 2019-12-01 10:59:56

问题


We are in the process of changing our SCM to BitBucket. Currently we use Clearcase SCM and there we have code in different stages / streams - Dev, UAT and production, where dev has code that developers are currently working on, UAT has completed changes being tested by BPs and Production has code that is deployed to production.

In BitBucket, our admins have defined 3 branches: develop, test and master.

For one of our applications, in CC, we have code in each of the states, so I was trying to add code from dev stream to develop branch in BitBucket.

I am using a brand new created repo. All the branches in the repo have a README.TXT file.

The commands I am using are

# 1.    create a Project & Repo in Bitbucket named __apprepo_
# 2.    create a Snapshot view on your workstation from Clearcase for the application that you want to migrate
# 3.    at the DOS command line, change directory to the root of your snapshot view
# 4.    type ‘git init’
# 5.    type ‘git add --all’
# 6.    type ‘git commit –m “Initial Commit” ‘
# 7.    type ‘git remote add origin ssh://ourBBserver.com:7999/EN/apprepo
# 8.    type ‘remote –v’
# 9.    type ‘git pull origin develop’
# 10.   type ‘git push –u origin develop’

When i run #9, I get the following error :

error   22-Jul-2016 20:45:10    warning: no common commits
error   22-Jul-2016 20:45:10    From ssh://ourBBserver.com:7999/EN/apprepo
error   22-Jul-2016 20:45:10     * branch            develop    -> FETCH_HEAD
error   22-Jul-2016 20:45:10     * [new branch]      develop    -> origin/develop
error   22-Jul-2016 20:45:10    error: src refspec develop does not match any.
error   22-Jul-2016 20:45:10    error: failed to push some refs to 'ssh://ourBBserver.com:7999/EN/apprepo.git'

But for #9 and #10, if I change develop to master, it works.

what can I do to move the code to develop branch directly? And same with test branch


回答1:


You don't need to switch to a ClearCase view and initialize your repo there.

Keep your local Git repo separate, ready to push to its remote repo.

Each time you want to add a coherent state from ClearCase, stay in your git repo and type:

 git --work-tree=/path/to/ClearCase/view/aVob add .
 git commit -m "Add state from CC view"
 git push

Then change the config spec of the CC view to its next baseline (or full label), in order to represent the next coherent state (since ClearCase is file-based, and has no notion of commits beside an UCM baseline).
And add again the new content of that same view to your same local Git repo (same branch). And push again.


My basic question is - If I have set of files that I want to add to develop branch instead of master branch and I did a ‘git init’ -> ‘git add --all’ -> ‘git commit –m “Initial Commit” ‘ -> ‘git remote add origin ssh://ourBBserver.com:7999/EN/apprepo' ,

First: don't git init. If you have a master branch that means you already initialize a repo somewhere else.

Go to that repo, create a develop branch and add the content matching the CC view set for that CC develop branch

cd /path/to/my/repo
git checkout -b develop
git --work-tree=/path/to/ClearCase/view/aVob add .
git commit -m "add content of CC develop branch (no history though)"
git push -u origin develop


来源:https://stackoverflow.com/questions/38537310/bitbucket-add-to-develop-branch-directly-instead-of-master

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!