Create branch in Google Cloud source repository - google-source-repositories

I have created repository in google cloud source repository . It got created with default branch "Master" , i want to create repository with two branch or need to add branch but i am not getting option.
Can anyone help?

I got the answer to my query.
Go to Git terminal and run below
1)git: git branch
2) git push -u
Refresh repo in GSR.

open the Git Terminal
git branch <branch-name>
this command will create the local git branch
git push -u origin <branch-name>
this command will push that branch local branch in google source repository
Now refresh the GCP source repository branch will reflect there
To get the access of that branch checkout to that branch
git checkout <branch-name>
Now you can perform pull/push operations on that branch

Related

Git mirror setup with bare upstream repo for Gogs

Given an existing bare repository on a network share, I'd like to be able to use Gogs for issue tracking (etc.) without disrupting the workflow for everyone else who's already using the bare repo.After reading up a bit, I was under the impression that a mirror would provide this functionality, and I would be able to set it up in Gogs through a Migration. When adding a Migration in Gogs by providing the path to the network bare repository and selecting "This repository will be a mirror", however, I get the following error:
Migration failed: check bare: exit status 128 - fatal: bad object HEAD
Looking at the log, I can see the following:
2016/06/13 13:19:20 [T] action.newRepoAction: myuser/the-repo-name
[git-module] git clone --mirror --quiet X:\path\to\bare\repo.git X:\path\to\gogs\repo.git
2016/06/13 13:19:30 [W] Delete repository wiki [X:\path\to\gogs\the-repo-name.wiki.git]: exit status 2
Strangely enough, I can issue git clone --mirror through git bash and have it execute successfully.
$ git clone --mirror /X/path/to/repo.git my-mirror.git
Cloning into bare repository 'my-mirror.git'...
done.
My questions are the following:
Is this set up possible? That is, can I commit to the Gogs mirror and have my commits pushed upstream to the bare repo, and viceversa (commits from other users to the bare being synchronized with my Gogs mirror)?
If so, how can I get this to work on Gogs?
Many thanks in advance!
PS: I also get the error above when attempting the Migration on a brand new bare repo, so I wouldn't think the issue lies in the bare repo itself.
After trying this again on the last release of gogs (v0.9.13), the issue seems to have been fixed.

Git directly commit file to git and/or gitlab

So, here's my use case:
I'm attempting to develop an internal Mac app for the non-developers on my team, to edit some of my game's parameters. Ideally, the application will be able to recreate the necessary config files and directly commit/push them to my gitlab instance, which would trigger a CI build.
I know I could programmatically clone my repo to their machine and then edit it programmatically and commit the changes, but I'm trying to avoid having to have each user who is only editing a few files cloning 2+GB of code.
Any suggestions how to commit directly to a remote repo? In this case, both the user and my server can be considered "trusted". Thanks!
That would look like those config file could be in their own (very small) git repository, and kept in the main repo as a submodule.
However, once a submodule has been pushed back, a hook should make sure the parent repo update its submodule reference (git submodule update), and add+commit the new SHA1 of said submodule which was just pushed.
Otherwise, the parent repo wouldn't realize that its submodule has changed.
That also means the parent repo should declare that submodule as following the latest SHA1 of master branch:
git submodule add -b master /url/to/submodule
For something as restricted as this a single-repo solution would also work:
Make a configs-only branch:
git checkout --orphan configs
rm all but configs
git add -A
git commit -mconfigs
git checkout main
git push server configs
In the config-editor repos:
git init configrepo
git remote add server u://r/l
git fetch server configs
git checkout -t server/configs
# work work, then
git commit -am "new configs"
git push
As part of your build,
git pull -Xtheirs configs

How to import local git repository into svn?

I am working on local git repository and I need to push my local git into existing svn repository. My git repository is pure local git repository, it was not init using git svn clone.
How can I import this local git repo into svn?
Preferably I'ld like to keep the git history being imported into SVN.
Currently the SVN repository is structure as:
https://svnrepohost
/branches
/tags
/trunk
/projectA
/projectB
/newProject
What I need it is to import my git repository into the https://svnrepohost/trunk/newProject above, assuming the newProject folder is empty.
I have finally solved this problem by the following steps:
Setup appropriate project folder in svn to be imported to, for example http://svnrepo/svn/trunk/newProject
Create a new git-svn repository
git svn clone http://svnrepo/svn/trunk/newProject
Add the git repo that we want to import as remote to the new git-svn repo
git remote add origin ../original-git-repo
Pull all the data from original-git-repo
git pull origin master --allow-unrelated-histories
Rebase local repository against svn
git svn rebase
Commit the changes into svn
git svn dcommit
Clean up the remote
git remote delete origin
The easiest way to do this is to just svn import the Git directory. That will lose you your Git commit history, however.
First of all, make sure the .git directory won't be imported by setting the global-ignores in the Subversion config file. Open your ~/.subversion/config file (that'll be in something like C:\Users\username\.subversion\config on Windows), find the section starting [miscellany], and add a line directly underneath reading as below:
global-ignores = .git
(if you already have a line with global-ignores = that doesn't have a # in front of it, then just add .git to the end of that line.)
Next, run the below:
svn import <path-to-local-git-repository> https://svnrepohost/trunk/newProject
That should copy the contents of the local Git repository onto the server exactly where you want it.
You may use SubGit.
$ svnadmin create repo.svn
$ subgit configure repo.svn
...
CONFIGURATION SUCCESSFUL
Adjust '/tmp/repo.svn/conf/subgit.conf' file
and then run
subgit install "repo.svn"
to complete SubGit installation.
$ nano repo.svn/conf/subgit.conf #edit to set git.default.repository=path/to/your/bare/git/repository
$ subgit install repo.svn
I would also recommend you to create a bare clone of your Git repository and to specify path to it (in git.default.repository) instead of your original repository. I.e.
$ git clone --bare path/to/your/original/repository path/to/your/bare/git/repository
After "subgit install" command the repositories (repo.svn and repo.git) will be in continuos synchronization (triggered by pre-receive hook in Git [that starts on pushing to your bare repository] and pre-commit in SVN). To stop synchronization you may run
$ subgit uninstall repo.svn
git svn clone http://svnrepo/svn/trunk/newProject
git remote add origin ../original-git-repo
git fetch origin
git checkout -b lmaster remotes/origin/master
git rebase master
git svn rebase
git svn dcommit

Restart Git repo Xcode 4.3.2

For different changes I made in my project, I need to restart Git repo and start with a new fresh version with the current project. How can I achieve this?
Many thanks
fire up your terminal:
go to project
cd myPath/MyProject
delete the current repo on your disk - your git repo = RIP
rm -Rf .git
init a new repo
git init
add your project to the new git repo
git add .
commit
git commit -a -m "init Project XY"
check if the repo is o.k
git status
What you want to do is create a new empty branch without any history. That way you start fresh but still have the option to return to your previous content. Inside the git repository, enter these commands:
git symbolic-ref HEAD refs/heads/<branchname>
rm .git/index
git clean -fdx
After that you are in the same situation as with an empty repository (i.e. start adding and commiting files) except that the history still exists in your old branches.
Note that all files you don't have in your old version will be permanently removed.

Repoint git-svn master branch back to trunk

I'm not sure how I got into this state, but my master branch on my local git-svn repo seems to be pointing to the remote UAT branch.
git status
# On branch master nothing to commit (working directory clean)
git svn dcommit Committing to https://svn...com/MyRepo/branches/UAT ...
how do I fix this?
I think what you're trying to fix is that your local "master" branch is based on the remote UAC branch, as opposed to the remote trunk. If you're happy to lose your commits, you can simply run the below, which will checkout the trunk and then move the master branch to your current point.
git checkout remotes/trunk
git checkout -B master
If you don't want to lose your commits, git rebase is your friend. Use the below:
git rebase $(git merge-base remotes/UAC master) master --onto remotes/trunk
This works out the common parent of the UAC branch and the local master branch, makes all the commits from there to the tip of the master branch onto the trunk, then moves the master branch to point there.
One way would be to rename the current master branch and to checkout origin/trunk as (new) master branch.
git branch -m master uat
git checkout origin/trunk master
If you need you can now cherry-pic commits from the uac branch to master (I would use gitk --all to help me with this)
A little more complex problem:
Rename master branch for both local and remote Git repositories