How to import local bare repo to Gogs? - gogs

I have a few bare Git repos on a host. Later I installed Gogs on same host. I configured it to use the exact same folder for storing repositories, where my bare repos are already residing.
How can I import them? I does not need to "import" anything in fact. I just want Gogs to recognize their existence.

I moved my repositories from one gogs-instance to another gogs-instance. But this should work with github, gitlab or other services as well.
Mirror the source repository to a bare git repo:
git clone --mirror git#source-gogs:project.git
Push the local bare git repo as mirror to the new destination repo:
cd project.git
git push --mirror git#dest-gogs:project.git
Note: Do not use git push --mirror if you did not clone the repo with git clone --mirror. Also, git clone --mirror is preferred over git clone --bare as it will clone all git notes and attributes as well.

Related

How to make Vercel clone submodule?

my hexo blog's theme is a git submodule,I want to use Vercel to display my blog.
But clone this project must to command git submodule init and git submodule update to clone submodule,Obviously Vercel don't do that.
enter image description here
OK, Vercel could clone submodules, It's my fault

Docksal and Git shallow issue

When I set up a docksal project, it uses git and the project folder ends up with a remote:
https://github.com/docksal/boilerplate-drupal9-composer.git
I then add another remote, to the repo for the codebase I am developing.
The problem is that the clone done by docksal was shallow, and when I try to push to my repo the push is rejected because of the shallow setting (the shallow file in .git)
Feel free to drop the .git folder and initialize a fresh git repo in the project folder Docksal created.
In case you'd prefer to inherit the boilerplate git repo commit history, you can always clone the repo directly:
git clone https://github.com/docksal/boilerplate-drupal9-composer.git drupal9
cd drupal9
fin project start

git submodule contents are not cloned along with the base repo

I created a repo:
git init --bare myrepo.git
Then on the same server, created the repo for production
cd /home/myuser/public_html
git init
git remote add origin /usr/local/gitroot/myrepo.git
git commit --allow-empty -m "Initial commit"
Then created the submodule
cd subdirectory
git init
git add .
git commit -m "Initial submodule commit"
cd ..
git submodule add /home/myuser/public_html/subdirectory subdirectory
git add .
git commit -m "Initial commit of base files and submodule"
git push origin master
Then on my local machine
git clone --recursive ssh://user#mydomain/path/to/git mygitdirectory
And at the tail end of what was looking like a clean clone, I get
fatal: repository '/home/myuser/public_html/subdirectory' does not exist
Clone of '/home/myuser/public_html/subdirectory' into submodule path 'subdirectory' failed
Trying git submodule add and git submodule update in subdirectory yields the same result. I ended up with all the base files, but the subdirectory being empty. On the server, git log shows the commit of the base files + submodule, and git status in both the base and the submodule shows clean.
Postscript
I blew away everything and tried again changing the submodule creation to:
git submodule add ./subdirectory ./subdirectory
which yielded a .gitmodules on the server of
[submodule "subdirectory"]
path = subdirectory
url = ./subdirectory
When doing the clone on the local machine, it resulted in the same error when it got to the submodule part. So, I changed the .gitmodules (and then did a git submodule sync) to:
[submodule "subdirectory"]
path = subdirectory
url = ssh://user#mydomain/path/to/git
Reading (many) different workflow suggestions, I find myself unsure (a) what the contents of each .gitmodules should be (I assume the server one is correct) (b) whether the remote bare repo to which the super repo on the server is pushed should be the only bare repo or whether the submodule needs one as well (I assume that once the submodule is committed in the super repo that pushing the super repo to the bare repo (origin) takes the submodule history as well), and (c) whether the local submodule needs to have a remote defined (it didn't appear to on the server, so I didn't so so locally)
Your local git is trying to clone the submodule using the remote URL that you originally cloned it from - which is a local path on the server and won't exist on your local machine.
Try cloning the submodule via SSH instead, so its remote URL will work on both the server and your local machine.

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