Search code examples
gitgithubgithub-for-mac

How can I use Git locally?


I'm working on a project at the moment, which I'd like to eventually make public on github, but, for the moment, needs to remain private.

Github needs users to pay in order to host a private repository, which I'm unwilling to do, so just creating a private github repository is not an option for me.

However, I would still like to use git for version tracking etc. whilst I'm working on the project locally, so that when I do eventually put the project on github, all of this information, the project's changes start-to-finish, will be available.

But, I have no clue how to use git without a remote server. I'm wondering now if it just exactly the same, simply without the need for git push.

The perfect answer for me would be a step-by-step walkthrough, telling me exactly what I should type into the terminal to set up and maintain a local git repository.


Solution

  • You only need to push if you want to use a remote server.

    When working locally, you still need to git init to set up the repository, but after that you only need to do the steps

    git add
    git commit -m "new commit"
    

    to save ("commit") your changes.

    Don't git push at all, and don't git pull — there's no remote to sync changes with (git push and git pull just push and pull changes from the remote/online repository).

    Type:

    git log
    

    To see that your changes have been recorded.