Sometimes you work in an environment where you have no control over a lot of things, and basic needs like setting up a fresh Git repo for your team takes days or weeks.
So what you do in the meantime?
Don’t waste a single hour for your team – just set up a shared-drive Git repository and start coding, committing, pulling and branching. When the real repository is set up by the infra team – just move your code there.
Below are the steps.
Step 1. Install git, open git shell. (download from http://git-scm.com/ – you can install both gui client and shell as you wish)
Step 2. In the git shell, navigate to your project
teamLead@PC /c/teamLeadWork/ $ cd /c/teamLeadWork/projects/myproject1
Step 3. Initialize git repository for the project (basically create a .git directory), add and commit necessary files. Edit .gitignore file and commit it too.
Example:
teamLead@PC /c/teamLeadWork/projects/myproject1 $ git init Initialized empty Git repository in c:/teamLeadWork/projects/myproject1/.git/ cat /c/teamLeadWork/projects/myproject1/.gitignore /target /.settings /.classpath /.project /data /log /bin # add this file to the index and commit $ git add .gitignore $ git commit -m "initial commit" [master (root-commit) 8bb532a] initial commit 1 file changed, 7 insertions(+) create mode 100644 .gitignore
Step 4. Clone the repo to your local drive. Assuming the shared drive is mapped as K:
teamLead@PC /c/teamLeadWork/projects/myproject1 (master) $ git clone --bare /c/teamLeadWork/projects/myproject1 /k/teamdev/git/myproject1.git Cloning into bare repository 'K:/teamdev/git/myproject1.git'... done.
Step 5. Add new remote repository to your project to be able to sync with the team members
# Tell git where your remote repo is $ git remote add origin /k/teamdev/git/myproject1.git # Now add tracking information for the current branch $ git branch --set-upstream-to=origin/master master Branch 'master' set up to track remote branch 'master' from 'origin'. # now Team lead can pull and push his changes and sync with the team
Step 6. Now other users can pull the project and push updates:
# Another team member: developerA@PC2 /c/devWork/projects/ $ git clone /k/teamdev/git/myproject1.git Cloning into 'myproject1'... done. $ cd myproject1 # Verify the origin is indeed from K drive $ git remote show origin * remote origin Fetch URL: K:/teamdev/git/myproject1.git Push URL: K:/teamdev/git/myproject1.git