How to put a local repo project into gerrit? - gerrit

I have a local repo project in ~/code folder, and I also have a gerrit in this server machine(assume its ip is 192.168.136.11), how can I move this local repo into gerrit because we want to use the gerrit to review the codes when developers push the new codes.

Move the repo's .git folder to gerrit's git folder
$ mv -r ~/code/.git $GERRIT_HOME/git/
Restart gerrit
$ GERRIT_HOME/bin/gerrit.sh restart
Should be updated now.
Restarting the service might require superuser priveleges.

Related

How to use Docker with git worktree

I recently started using git worktree and it is awesome. However, I am not sure how to make it work with Docker. Here is my flow:
repo-a has a dockerFile to build a local container.
I create a new worktree like git worktree add branch-a this will create a folder named branch-a with branch branch-a.
I received a PR to review and I need to switch to branch-b. So I go back to my --bare clone repo and I do git worktree add branch-b. and cd into that folder.
My docker container doesn't catch new files because it is still linked to files on branch-a and if I do docker-compose up -d on branch-b, it throws an error saying that The container name "/<name here>" is already in use by container "31344e3448df72e032c42a96d078ea57c11a75023d197e9ab0683e7c773f54e4"
How can I make my docker container to listen to changes on a different folder?
Thanks
Perhaps a simple way to do this is to have a symlink from the directory Docker expects the files to be. And the symlink points to the actual directories of the different branches. You update the symlink each time you need to work on one of the different worktree branches.

Add project files from Local machine to Github Repository

I am working on an iOS project. our employee has created a repository say app and we have a master branch by default. employee has created another branch say "second" now I need to upload my project files from my machine to Github repository's Branch "Second" looking into a lot of tutorial and didn't understood what and how to do that... This question may have already asked but sorry didn't helped any...
At first, make full backup of your project, so
you can restore it if something goes wrong.
If you have local git repository (in terminal you can see .git and .git**** files after execute "ls -la" command in project directory):
1) Open your project folder with your local git repository in Terminal and add your Github repository as origin:
$ git remote add origin https://github.com/your_user/your_repo.git
(This url you can see at Github repo)
2) Push all your local branches onto repository:
$ git push --all origin
If you do not have local git repository:
1) Create new folder, go inside it and in Terminal execute this:
$ git clone https://github.com/your_user/your_repo.git
2) Copy all your iOS project (with inner files/folders/etc) into that folder
3) Add all your local files into local git repo:
$ git add .
4) Commit all changes:
$ git commit -m initial
5) Push all your local branches onto repository:
$ git push --all origin
Also see Github help:
https://help.github.com/articles/adding-a-remote/
https://help.github.com/articles/pushing-to-a-remote/

share git repo between two computers locally

I'm working on an Xcode project and my brother wants to start helping out. I have the .git folder in my Xcode project directory, how can my brother pull / push / commit to / from my computer? Do I have to use OS X server and put the repo inside of there, or is there a simpler way to do this?
One simple option is to enable "remote login" in sharing, which enables ssh, then you can use the ssh protocol to clone the repository. Remote login preferences will tell you:
To log in to this computer remotely, type "ssh username#computer.local".
username#computer.local will be replaced with your username and hostname. In terminal, use:
git clone username#computer.local:[path]
on your brothers computer to clone the repo to him, where [path] is the path to the folder containing the repository. You will need to enter your password, and you will need to enter it in order to copy changes back later with git push or whatever.
You can set up passwordless ssh with private keys, but bear in mind that by doing this you are effectively giving your brother entire control of your computer.
If you want to push code between two non-bare repositores, I recommend having a look at git-annex.
It is usually used for syncing large files between repositories, but it also contains a nifty way of syncing non-bare repositories (pushes go to synced/master branch that is automatically merged).
Basically, if one can write a ls path or ssh [user#]host:path ls command that would list your repository, then you can use the corresponding git clone [[user#]host:]path [optionalNewName] to clone from it.
Also if he (or you) is working on the same local machine, or has access to the local filesystem, one need only point to either the .git directory or the directory containing the .git directory.
To make clone a repository into another directory:
git clone . ~/2015Archive/repositoryB # copy pwd's repository elsewhere
git clone .git ~/2015Archive/repositoryB # same
git clone ~path/path/repositoryA . # clone other repository into pwd
git clone /home/brother/2015/projects/CoolProject ~/WORK/BrosCode
# with ssh from a remote machine
git clone me#brosmachine:/home/brother/projects/CoolProject WORK/BrosLameCode
git clone me#brosmachine:../brother/projects/CoolProject WORK/BrosLameCode
If you change into the target repository and do a git remote -v it will show you an absolute path to the 'origin' from which it was cloned. If it was a local dir, it will be just a plain, absolute path. If it was accessed through ssh, it will be a ssh [user#]host:path identifier.

Accidentally created a git submodule

So I was developing a API Client gem, which was working great, had it's own github repository and my team lead decided that he wanted me to move this client api into the api repository itself. So I copied the files over into it's own directory, removed the .git directory from the client's directory, and merged it into master. Worked great.
However, now when I try to create a branch off of master, the directory shows up a submodule on github, and isn't tracked in my local git. There is no .gitmodules folder, and no mention of submodules whatsoever. I can't create a new branch because it says that there are untracked files that will get overwritten (all the files in my client gem directory) but as far as I can tell there's no way for me to start tracking these files. I can access the directory just fine, but as soon as I modify a file, the change doesn't show up in the api projects git.
What do I do?
If there is no .git folder or file in that subfolder, all you need to do is git rm --cached [folder] followed by git add [folder]/*
Running git rm --cached --ignore-unmatch client then allowed me to git add client/

Heroku -- Push new content to a heroku app created from a different machine

Our team is working on an app. We have a SVN based app. We also pushed the app to heroku. The other day the app was pushed by one member of the team, and after a couple of days of work and making some updations other member wants to push his data on heroku in the same repo from another machine. How can this be done?
Please Help.
Thanks in Advance.
You need to use Git to push applications to Heroku. If your source control of choice is Subversion, then you can use git-svn to deal with a Subversion repository using Git, including pushing to Heroku.
You need to add a git remote to the Heroku Git URL. You can find this URL in your Heroku account at heroku.com.
# stuff about setting up git-svn
$ git remote add heroku #{heroku_git_url}
$ git push heroku master
As another commenter mentioned, you will also need to manage SSH keys. The user doing the pushing will need to have an SSH private key (you can look up ssh-keygen) and will need to have the SSH public key uploaded to Heroku (heroku ssh subcommand).
So if your app is deployed and you already have a working copy. And you need to push changes.
You only want the repo with no content.
git clone --no-checkout git#heroku.com:<your-app-name>
That will clone the repo into a directory named your-app-name, and in that directory will be the repo you want. Move that .git file next to your .svn file.
mv <your-app-name>/.git ~/Code/<your-working-copy>
rm -rf <you-app-name>
You can rename the origin remote to heroku if you want. Otherwise just
git commit -am "Deploying v1.2"
git push

Resources