Search code examples
gitrepositoryworkflowgit-pushgit-remote

Simple GIT workflow for small website development by one


I'm new to git, trying to get my head round it.

So I'm developing a simple website locally and tracking it with git and want a remote repo on the public facing server to be the live site, to which I can push the master branch whenever I'm ready to do so.

I thought the following would work but it doesn't.

Public server I did this:

/home/mysite/git init --bare

Local (development machine) I did this:

git init
git add index.html (contains hello world)
git commit -am "initial commit"
git remote add website ssh://mysiteuser@mysite:myport 
git remote (outputs: website)

Now I want to publish this to the 'website'

git push website

And I get:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream website master

So I try:

git push --set-upstream website master

And I get:

fatal: No path specified. See 'man git-pull' for valid url syntax

I looked in man git pull and it sheds no light for me.

Am I doing this right but missing something in the push command? Or have I misunderstood something more fundamental.

TIA!


Solution

  • I suspect my original question was misunderstood by those good people who tried to help me. To re-iterate - I want to have the development repo locally, and when I 'push' have it automatically update the files on my web server so that the website project is pushed live on my whim.

    Here's how I've done it...

    ON REMOTE (WEB SERVER)

    mkdir website
    cd website
    git init
    // here's the clever bit!
    git config receive.denyCurrentBranch updateInstead
    

    (That last line does two things. It stops the remote repository from complaining about an update to the checked out branch - and it also checks it out straight away. Other methods commonly used add a 'hook' to do the latter part of the process.)

    ON LOCAL DEVELOPMENT (MY LAPTOP)

    cd ~/website-dev-folder
    git init
    git remote add website ssh://my_user_name@mysever.com:my_port/home/website
    git add some_file.html
    git commit -m "initial commit"
    git push -u website master
    

    Henceforth after any local change is finalised and merged into master, to publish the master branch live it's a simple:

    git push