skip to Main Content

We have wordpress website and hosted on server. We got to know that GIT us already installed on our server. We checked it as well by ran command git --version

What we are trying is to push code from server to bit bucket via command line/SSH.

We have followed following steps but unable to complete process :

  1. Created account on bit bucket.
  2. Created blank repository
  3. Run command git init <directory>, We can see .git file into server where code exists. i.e [public_html/website/]
  4. Run command git add
  5. Now really confuse that what we should do next? Should we create clone or add remote origin?

From SSH, We have run command git remote add origin [email protected]: pathtogit

But above command is not working[It returns me usage of command].

Have done lot of research for easy steps to push code from server to bitbucket but every search result has diff. methods and I am confused.

If command line is difficult then any easy way to achieve it via sourcetree?

3

Answers


  1. What you have to do after step 4, is to add the remote repo:

    git remote add origin https://github.com/user/repo.git

    Then git status to see if the files you want to push to bitbucket are there. If they’re not:

    git add --all
    

    Then you commit your changes:

    git commit -m "My first commit"
    

    And finally you push to the server:

    git push origin master
    

    Where master is your branch.

    Login or Signup to reply.
  2. git remote add origin [email protected]: pathtogit
    

    You are having one space between host and path. The correct command should look like this:

    git remote add origin [email protected]:pathtogit
    
    Login or Signup to reply.
  3. I have tried and tested this and it works.

    login using ssh
    go to public_html directory

    Now type the following command

    git clone repository_name 
    

    where repository_name is your bitbucket or github repo name

    after you clone the repo you will get a a git folder

    copy the .git file in you main root folder.

     git add .     
     git commit -m "message" 
     git pull origin master
     git push -u origin master
    

    where master is your branch

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search