How can I use Git locally?

GitGithubGithub for-Mac

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

A remote server is never required. You can just do git init in your project. If you decide to add a remote server later, it will maintain all the history when you push it.

Also if you want you can use Bitbucket or GitLab. Both of them allow private repositories for free.

Solution 2 - Git

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.

Solution 3 - Git

Actually you just have to run

git init

on your local folder. This will already create you a repository within the existing folder as a minimal setup.

If you would like to have a setup more similar to a distributed setup with a repository at some other place/server, use

git init --bare your_project.git

to create a repository (similar to the server side repository), and

git clone <path_to_repository>

in the local folder where you would like to work

Solution 4 - Git

Just make a local git project and dont push it. You can do it later. Or you make a empty github project and pull the empty project. Now you can work locally and if you are ready you can push it to github.

No worry, just try.

Solution 5 - Git

Git allows you to create a local repository on your machine. Only when you're actually ready to publish it to a remote is when it becomes available to the public.

Otherwise, it's no different than working with Git without an internet connection; you can still commit, tag, rebase, create branches, and all of that wonderful stuff, but you can't push or pull.

In the project directory, initialize it just like you would any other Git project.

git init

Work on it like you would any other Git project with commits. Since you don't have a remote server to push it to, any attempts to push or pull would fail anyhow.

When you're ready to create your remote server, GitHub will do a very good job of walking you through what you have to do in order to get that bootstrapped.

Solution 6 - Git

I'm dealing with the same thing. Unless that I cannot really have a private project on Github, because of unfair sanctions to some country. I don't want to repeat the other answers, because they were straight forward, and I'm doing just the same. To add a bit information, if you don't like terminal environment and you don't want to go through every change and record them by your terminal, simply install Atom editor, install the Github plugin, in newer versions the plugin installed from the beginning and you really don't need to worry about it. When you created a folder you can initialize the git by either the Git icon or simply typing in the terminal at the exact directory :

git init

Then, when you add changes to your code or whatever, the git tracks it and you can commit your changes through the Atom editor. enter image description here The only problem might be that you cannot use all of the commands that are available via terminal, but it's enough to actually work. But you can fill the gaps by using the terminal when you really need other git commands. This plugin is available on other IDEs as well. And works just fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontheonlygustiView Question on Stackoverflow
Solution 1 - GitjfadichView Answer on Stackoverflow
Solution 2 - GitrikardView Answer on Stackoverflow
Solution 3 - GitnogeniusView Answer on Stackoverflow
Solution 4 - GitrecyclerView Answer on Stackoverflow
Solution 5 - GitMakotoView Answer on Stackoverflow
Solution 6 - GitNosrat MohammadiView Answer on Stackoverflow