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 :
- Created account on bit bucket.
- Created blank repository
- Run command
git init <directory>
, We can see .git file into server where code exists. i.e [public_html/website/] - Run command
git add
- 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
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:Then you commit your changes:
And finally you push to the server:
Where
master
is your branch.You are having one space between host and path. The correct command should look like this:
I have tried and tested this and it works.
login using ssh
go to public_html directory
Now type the following command
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.
where master is your branch