0

I am new to git repositories. I tried my best to learn about it. I need to push a automation project to google repositories .I executed following comments to perform this.

$ git init
$ git add .
$ git commit -m "initial commit"
$ gcloud init && git config credential.helper gcloud.cmd
$ git remote add google https://source.developers.google.com/p/[PROJECT_NAME]/r/[REPO_NAME]
$ git push --all google

I managed to successfully pushed the project however it is not reflecting on the default branch of repository. When I navigate to the repository it shows

No commits on the default branch. Push code to the default branch or switch branches.

It looks like main is not a default branch ,there are multiple branches in the cloud

enter image description here

I tried to merge but still no improvement

$ git remote
google
$ git fetch
$ git checkout HEAD
Your branch is up to date with 'google/main'.
$ git merge main
Already up to date.

I need to merge my main branch to default branch on google cloud repositories. Please help

Siraj
  • 1
  • So, which branch *is* the default branch in the hosted repository? Is there way to *set* the default branch in the hosted repository? If so, consider using that to pick the branch name you'd like it to use as the default. – torek Nov 07 '21 at 09:01
  • @torek , Thank you for the reply . There is no options to set the default branch. The Branch menu displays only one branch which is "main" .However when i navigate to repository default page then I can see "HEAD" is coming as a branch name where i am NOT able to git checkout HEAD using the bash. – Siraj Nov 07 '21 at 10:53
  • Interesting: GitHub, Bitbucket, and other providers give you a web interface by which you can choose the default branch name. But if GCP do not do this, you'll just have to create a branch named whatever-the-actual-default-is (probably `master`) in the GCP-hosted repository, to make the complaint stop happening. [I would suspect that GCP have a way to set the branch, but this SO Q&A says not.](https://stackoverflow.com/q/62669622/1256452) – torek Nov 07 '21 at 12:00
  • Meanwhile: in Git, `HEAD` (in all uppercase like this) is a special name that means *the current commit* and *the current branch*. So there is no *branch* named `HEAD` (technically it's possible to create one, but this is a bad idea because then you can't *name* it any more as the *special* name is in the way). The command `git checkout HEAD` just means "check out the branch I have checked out", which is a weird way to run a limited version of `git status`. – torek Nov 07 '21 at 12:04
  • @torek,Thank you so much, Created branch named "master" ,$git push --all . Now master become default branch , Everything fine. Thanks again – Siraj Nov 07 '21 at 14:05

0 Answers0