Pango
Pango

Reputation: 13

How to set up a git repo with existing sources

I am new to git and I have difficulty understanding some functioning.

I have 1 production server, 1 staging server and 1 development machine.

Of these 3 machines, I have the sources of the application. I would like to connect each machine to the repo git I created and more precisely, I would like to create 3 branches (master, staging, prod) and connect the production server to the prod branch, staging server to staging branch and development machine to the master branch.

I can not create this system and import the sources into the branches ... I'm lost with git commands...

Please, how can I proceed ?

Upvotes: 1

Views: 279

Answers (1)

ashmaroli
ashmaroli

Reputation: 5444

  1. git init to initialize a git repo.
  2. the repo is empty. So easily create branches for production and staging:

    git branch production
    git branch staging
    
  3. the default branch is called master. So, add your development code into it.

  4. add the code to git index and commit.

    git add .
    git commit -m "init development source code"
    
  5. Checkout the production branch and repeat steps 3 and 4.

     git checkout production
     [...]
     git add .
     git commit -m "..."
    
  6. Repeat for staging

Upvotes: 1

Related Questions