I have some rails code that is hosted on a private github repo however I want to move that code to my own git server and do away with github. I have a server and git setup already, however if I do a git clone (github location) wouldn't that still be using github as a remote? What is the proper way to do this?
A git clone is a complete copy of the remote repository.
You can use git clone --mirror on your private server, in order to set up an exact mirror of the remote, followed by git remote rm origin to remove references to the original (however this is not necessary for it to function properly).
After this, all you have to do is clone the repo from your new, private source, instead of github.
(You can also use git clone --bare instead; Differences between --bare and --mirror are explained here).
Related
Before posting this question I have looked through all the similar ones. Finding no workable solution I am asking for help.
Thanks in advance!
I am trying to copy the repository from one tenant to another one using the following approach:
(done) Download the tool: Download Microsoft Git-TF for Visual Studio Team Foundation Server and Visual Studio Online from Official Microsoft Download Center
(done) Download Git-TF and Git-TFS (done with using git-tfs)
Clone an existing TFVC repo to my local machine as a Git repo using the Git-Tf tool: git-tf clone https://dev.azure.com/myorg/ "$/mysourceteamproject/mysourcebranch" --deep git-tf is no longer supported so I used git-tfs here. git-tfs clone https://dev.azure.com/myorg/ "$/mysourceteamproject/mysourcebranch" --deep
(done) Cd into the directory that the code was cloned into and push the local Git repo to any empty remote Git repo (this will be used as a temporary repo during the migration) git remote add origin https://user#dev.azure.com/myorg/anyteamproject/_git/tempgitrepo git push -u origin –all
(done with using git-tfs) Cloned the temporary Git repo to my local machine git-tfs clone https://user#dev.azure.com/myorg/anyteamproject/_git/tempgitrepo
(done ) Created an empty new folder “migrated” in the existing target TFVC repo (done with git-ft but from this step I am not sure it is a correct approach now) Cd into the directory that the code was cloned into, and run the configure command: git-tf configure https://dev.azure.com/myorg/ "$/mytargetteamproject/migrated" (here git-tf does not due to Basic Authentication issue as it is no longer supported. Using gif-tfs led to bootstrapping to the tenant we would like to copy from - to original )
Run the pull command to merge two repos does not work - git-tf pull leads to bootstrapping to the wrong tenant - git-tfs pull the steps below simply cannot be executed as the step 8 cannot be completed properly.
Run a basic git commit command git commit -a -m "merge commit"
Checkin to the TFVC repo git-tf checkin –deep --metadata
The question is - is there a way to move TVCS repo from one tenant to another TVCS tenant repo?
Finally, I managed - of cause not only me - to do migration.
Unfortunately, git-tfs could not be used as it works not as git-tf.
The main issue was Authorization step with using git-tf.
Using token name and token as user name and password accordingly helped a lot.
All the steps done can be seen below:
Install GIT, GIT-TF, Java
To clone source repository to local GIT
git-tf clone https://azerov:[source token]#dev.azure.com/OrganizationName "$/D365FOps_Learn02/Trunk" --deep
username: TestPatMigration (the name of the token)
password: [source token]
Create any remote GIT repository to push local cloned repo there
cd into cloned repo c:\users[curuser]\Trunk
git remote add origin
https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/GitTemp02/_git/GitTemp02**
To push local cloned repo into temporary GIT repo
git push -u origin –-all
To clone temporary git repo to local machine
git clone https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/GitTemp02/_git/GitTemp02
To configure the target TFVS Project to push local temporary GIT repo there
cd into c:\users\GitTemp2
git-tf configure https://azerov:[git temporary target token]#dev.azure.com/OrganizationNameTarget/ “$/D365FOps_learn02/Trunk”
git-tf pull
Username: PATMigration (the name of the target source token)
password: [git temporary target token]
git commit -a -m "merge commit"
git-tf checkin –-deep –-metadata
I have a git repository that contains two directories:
src: A full Rails app
devbox: Files to build a vagrant machine and provision using an Ansible script
I wish to split these out to two separate repositories so I have one solely containing my app and another containing the vagrant devbox.
This SHOULD allow me to add the app repo as a git submodule inside the devbox one in order to be worked on but at the same time allow Capistrano to grab the source from the app repo without any faffing around to only get a subdirectory of the full combined repository.
Any thoughts about how to go about splitting the current repo up? I'm just a bit unsure where to begin.
move the devbox folder out of the repo.
mv devbox ~/Projects/
move the src folder out of the repo.
mv src ~/Projects
create two empty repos on your github account for both devbox and src
initialize devbox as git repo cd ~/Projects/devbox && git init
Add the git remote. Instructions provided when you created the git repo on github. git add remote ...
Push the repo to github git commit -am'initial commit' && git push origin master
Repeat steps 4-6 for src
First - I've created the git repository and also created the local repo of the same on my local system.
Second - Worked on my local system and did some changes and pushed the changes on to the Git repository such that my local system source and git repository are in sync now
Now, Instead of working on my local system, I wanted to work on NitrousIO. Hence created the folder same as my git repository name and did 'git .init' as well. Basically this is the Ruby on Rails application, hence followed 'rails new RKsJobs_Board' to set up the folder and then git .init
What I need is:
As the remote git repository is up-to-date with the source code, I would like my NitrousIO folder to be in sync with the remote repository.
How can I achieve this ?
I tried this on Nitrous from the root directory like below:
action#rksrailszone-182221:~$ git checkout -- RKsJobs_Board
error: pathspec 'RKsJobs_Board' did not match any file(s) known to git.
I also tried this on Nitrous from the actual directory like below:
action#rksrailszone-182221:~/RKsJobs_Board$ git checkout -- RKsJobs_Board
error: pathspec 'RKsJobs_Board' did not match any file(s) known to git.
I know something fishy is missing to get it work but unable to find out myself.
Let me know if you guys can help..
If you just did a git init ., the local git repo is empty and has no index for you to checkout.
You would need to add a remote repo url
git remote add origin /url/to/remote/repo
git fetch
git checkout master origin/master (or) git checkout master && git reset --hard origin/master
That would give you the content of the remote repo in your local repo history and working tree.
Note - Before following the steps, please ensure to have the empty folder then start with git init . and other steps mentioned above
I have git repo of an iOS project on github and want to duplicate it and make a new project based off it?
How can I do that? Branch then ???
I don't just want to branch I want an entirely new project that is disconnected from future changes to the original project.
You have to fork repository from your original one from github website. Then you have to clone that repository into your machine. So now new repository will be independent from your original repository,
Clone the project.
Delete the .git directory.
Do the git init, git add ., git commit dance.
You could use git archive:
git archive --format=zip --prefix MyNewProj/ HEAD -o ../theproject.zip
cd ..
unzip theproject.zip
cd MyNewProj
git init
git add .
git commit -m "initial commit of completely original repo"
This will create a zip archive of all tracked files (not any ignored, like binaries). Then you can unzip it into a new project.
After this you can create a new repo on github (do not initialize it) and push to that.
git remote add origin https://github.com/yourgithubaccount/MyNewProj.git
git push -u origin master
I was using git on Heroku, and everything was going very good. Now I am trying to use git on a VPS server, but I can't make it work.
I am doing it on terminal over ssh. It's a rails app. When I create a new rails app, I do git init git add . and a commit. On the server, I create a bare repo with git init --bare. It just fails when I try to push it.
Then I have tried to upload files to the server manually, create a repo there and clone it locally, but when I do changes locally, commit it and would upload them, it also fails.
I really did a few things more, trying to figure it out by myself what is failing. Got a lot of different errors and different ways of doing it... I read different tutorials, even my own server provider as one I followed and got errors.
When I got error messages, I've tried to find a solution, but I am not able in the end to make a push. Well, in some cases push goes well, but remote repo doesn't seems to change (and no errors after git push).
The last 48 hours I am literally just on the computer trying to make this work, everytime starting again and trying different things.
I think for once I was just one step from doing it right. Just realized after (and can't remember steps I followed) that it could be something with using different branches, because I made that and it looked a bit strange (for me):
$ git branch -r
origin/HEAD -> origin/master
origin/master
$ git branch
* master
Strange because I think maybe there aren't listed the same remote and local branches.
So my question is really how to start a new git repo with a blank rails app, and upload everything for the first time to my server. Don't know if it matters, but I use ssh to connect to the server from terminal, server as Apache/Phusion Passenger.
I have actually all google results about this marked as visited, even most of questions on here related to my problems. So hopefully someone can tell me the right way.
Not sure why it's not working for you, but here's a different way of setting up a remote repo.
(The following is based off of Chapter 4.2 of Pro Git. See the link for a more thorough explanation.)
Create a "bare" version of your repo. Run this command from the parent directory of your git repository.
local$ git clone --bare my_project my_project.git
Copy the bare repository to the remote server. This example puts the bare repo in ~user/git.
local$ scp -r my_project.git user#your-remote-server.com:git
Now it should be accessible from your existing repository by running this command from your local repo root:
local$ git remote add origin user#your-remote-server.com:git/my_project.git
or you can clone the whole thing:
local$ git clone user#your-remote-server.com:git/my_project.git
Your steps seems to be good, nevertheless I'll provide them one more time
[user#server] cd path/to/repo
[user#server] git init --bare projekt
[user#home] git push user#server:path/to/repo --all
It looks like you are very close. On your development machine ensure that you have the proper remote defined:
git remote add origin ssh://<username>#<hostname>[:<port>]/path/to/repo/dir
and then make sure your push includes the branch as:
git push origin master
You'll get something like:
ebg#ebg(21)$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://gozoner#<hostname>:2222/home/gozone/git/foo
* [new branch] master -> master
My exact process:
$ mkdir /tmp/foo; cd /tmp/foo; touch foo.c; git init;
$ git add .; git commit -m 'foo'
$ ssh remote
> mkdir ~/git/foo; cd ~/git/foo; git init --bare
> ^D
$ git remote add origin ssh://.../home/gozoner/git/foo
$ git push origin master
[edit]
If you then look in the remote repository, at ~/git/foo in my example above, you will only see .git like files. To get the repository contents, to run your rails app, do a clone.
$ ssh remote
> git clone ~/git/foo ~/rails/foo
> cd ~/rails/foo
> # your files are there; run web server