Noble-Surfer
Noble-Surfer

Reputation: 3172

Git - creating a repo for a new user/ computer

How do I set up a local repository for a new user using Git?

I am working on a Python/ Django project, and a new employee will be joining me soon, so I need to set up their computer ready to access all of the files on the repository, and ready for them to begin development work on the project.

I had not used Git much previously prior to starting work with this company, and when I joined, someone else had already set up my development environment, so that I had the latest copy of the code copied from the remote Git repository to my computer, ready for me to start developing on- so setting up an environment for a new user with an existing project is not something I've ever done before.

I've had a look online, and it looks like I want to run a git clone of the remote repository from the new user's computer, but I'm not sure how/ where to do this from?

I am using a Mac (OS X Yosemite), and my colleague will be too. On my computer, my 'root' development folder is at:

Macintosh HD > Users > me > Documents > Dev > myProgram > root

This is where all of the Django Apps, .json files and other 'system files' for the software seem to be.

To replicate this setup on my colleague's computer, do I just need to create the folder structure:

Dev > myProgram > root

on their computer, then cd to that location using the command line, and run the git clone command from there?

I am aware that I will need the address of the remote repository, to give to the git clone command- as I understand, I would find this by running git remote -v from my computer? Is that correct?

Presumably then I would need to run git clone remoteAddress from Dev > myProgram > root on my colleague's computer?

Edit

I will obviously want to add the user to the Django project too- I tried doing this via www.mysite.co.uk/admin and going to Authentication & Authorisation -> Add User, I set up the username & password, and gave the user profile admin privileges. It said that the user had been created successfully, but when I tried to get hold of the user profile that I had just added in the command line, by running the following commands:

from employees import models

from employees.models import Employee

allEmps = Employee.objects.all()

newUser = allEmps.filter(first_name = "name")

newUser just became an empty array, so clearly the user has not been added to the database... If I run the same commands, but using my name, rather than the name of the user I've just tried adding, newUser holds an array of one element (my user account), which I can then assign to a variable in order to check its properties, etc.

How do I actually add a new user to my Django project?

Upvotes: 1

Views: 736

Answers (2)

sigy
sigy

Reputation: 2500

You are correct, git clone is the command you want to use. When you run git remote -v on your own machine it will show you the location of the git repository that you are using. Note, that it might look like [email protected]:/path/to/repo.git if you are using SSH. I.e. it might include your username. So you will have to substitute that with your new colleague's username.

Where you run git clone from is totally up to you, but building a similar directory structure as you are using might make sense. Just running git clone [email protected]:/path/to/repo.git would create a new directory repo and clone into that. This is because in the example the repository is called repo. But git clone optionally takes a second argument to name the directory it will clone into. E.g. running git clone [email protected]:/path/to/repo.git myapp will create a new directory myapp in the current folder and clone into that.

Also have a look at First-Time Git Setup if you want to set things like username, editor, mergetool, etc.

Upvotes: 1

Shivkumar kondi
Shivkumar kondi

Reputation: 6762

It is not at all about replicating folder structure.

As you can't move the installations from one to another.So you need to install in that newuser PC also.

He(new user) can work/install Django wherever he wants but I would recommend to keep apps separate/modular and Considering you kept apps modular,you can follow this steps:

Your Side :

  1. Find your remote and push your code to github/bitbucket(for each app)

New User PC :

  1. Make a folder with his name as : mkdir workspace_XXX
  2. Inside that folder,Make project folder as : project_xxx
  3. Inside that folder,Create VirtualEnv and Install Django /other packages
  4. Now create the project with same name
  5. now clone apps from git

Is it not recommended to make changes at django core but still some will do. If so,you can add those changes manually.

And I would recommend you to have some try about git here https://try.github.io/

Upvotes: 0

Related Questions