1

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

aynber
  • 22,380
  • 8
  • 50
  • 63
adbdkb
  • 1,897
  • 6
  • 37
  • 66

1 Answers1

0

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, @VonC. Can you explain a bit more? I want to add the entire set of files from each CC state to the corresponding branch in BitBucket. The way our clearcase is set-up is for different states, there are different streams - so I was planning on populating BitBucket such that CC _dev stream -> develop branch, , CC _uat stream -> test branch and CC _prod stream -> master branch. All the different branches have different files in the sense that files could have ben added from prod to uat to dev. – adbdkb Jul 23 '16 at 02:03
  • @adbdkb for each CC branch, you need to rebase from the oldest baseline to the newest, and for each one, add its content to the Git repo. The `--work-tree` option allows a git repo to temporarily consider another path (like the one of the updated CC view) as its working tree, to add/modify/remote the delta between its HEAD and the CC working tree. – VonC Jul 23 '16 at 02:06
  • But how can I directly add to develop branch using `git pull origin develop` or is that not possible? – adbdkb Jul 23 '16 at 02:07
  • @adbdkb that is a command from Git repo to Git repo. It has nothing to do wirth importing a CC branch to a local Git repo (which then will need to push, not pull, to a remote Git repo) – VonC Jul 23 '16 at 02:08
  • @adbdkb Remember: you are switching from CC to Git: you import from CC to a local Git repo, and then push to the BitBucket one. – VonC Jul 23 '16 at 02:09
  • @adbdkb Read also http://stackoverflow.com/a/12411240/6309 and its associated links (mainly http://stackoverflow.com/a/645771/6309 to fully understand the difference between CC) – VonC Jul 23 '16 at 02:11
  • please pardon my ignorance, still waddling through understanding git. So, how does the pull / push part in the above commands work? I guess, I muddled the question by mentioning CC part. 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' `, what should be my next command so that I can add to `develop` branch ? – adbdkb Jul 23 '16 at 02:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/118074/discussion-between-adbdkb-and-vonc). – adbdkb Jul 23 '16 at 02:17
  • It is 4am here. I am be back in a few hours – VonC Jul 23 '16 at 02:21
  • not sure how the chat part works @VonC. Didn't see your response yesterday in the chat session - so adding the comment. ( what I meant is saw it here, not in chat session ) What do I need to do to move the code - different sets of files - same common base but with additions / deletions between different sets - 1st set -> develop branch, second set -> test branch and 3rd set -> master branch. I still don't have the full grasp of how BitBucket works, still trying to figure out – adbdkb Jul 23 '16 at 11:15
  • @adbdkb this has nothing to do with BitBucket (or GitHub, or GitLab): all those repo hosting services work the same with Git. This has everything to do with how ClearCase work, compared to Git: a branch in ClearCase is *very* different from a branch in Git. – VonC Jul 23 '16 at 11:18
  • Thanks. I am going to try the chat part again and see if it works – adbdkb Jul 23 '16 at 11:19