1

I want to track my existing project for versioning needs only using local repository.

Do I have to push it to my local repository or is committing enough? Tutorials such as this describe tracking by only typing git init, git add and git commit. Also, how can I pull my previous version later when I need to?

Regarding I have already changed the current working directory to my local project by opening bash prompt inside the directory that my project is in, what steps should I follow?

I have used Github before and I know how to push the changes to a remote repo. But when it comes to local, I get confused.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
KontrCode
  • 89
  • 11
  • Committing already puts the changes into your local repo. Pushing and pulling is only needed to copy changes between _different_ repos. – Thomas Apr 04 '18 at 07:07
  • 1
    You seem to be confused about how Git works, and you left off some steps for what is needed to push a newly initialized local Git repo to GitHub. Long story short, when you commit locally, the work is there locally, but in GitHub. And you should always push your work frequently to GitHub, otherwise if something were to happen to your local computer you could lose work. – Tim Biegeleisen Apr 04 '18 at 07:10
  • @TimBiegeleisen the thing is I believe when I push my work in GitHub, it becomes visible to everyone. The reason I want to use my local repo is that I don't want to share my codes for my current project. – KontrCode Apr 04 '18 at 07:14
  • @KontrCode Nothing at all wrong with that. You could still push to a private GitHub repo (though they might read it, without telling you). Or, you can do what I do, which is to backup the entire project frequently onto an external drive. Or, you could backup your `.git` folder to an external drive. – Tim Biegeleisen Apr 04 '18 at 07:15
  • On BitBucket you can have unlimited private repositories. – Thomas Apr 04 '18 at 07:16
  • @Thomas well that might be a good info because GitHub charges for private repos I guess. – KontrCode Apr 04 '18 at 07:19
  • @TimBiegeleisen thank you for advices. Backing up the project onto an external drive might work for me. – KontrCode Apr 04 '18 at 07:20
  • Going beyond that, you may ZIP the project, encrypt it, and then even store it somewhere like Google Drive. This way, your work exists in 3 separate places at all times. – Tim Biegeleisen Apr 04 '18 at 07:24

1 Answers1

1

git push: Updates remote refs using local refs, while sending objects necessary to complete the given refs.

https://git-scm.com/docs/git-push

When you push, you actually update your remote repository with your local commits. So in your local repository, committing the changes are enough. To transfer these commit to the remote repository (like in GitHub) you have to push.

Bishakh Ghosh
  • 1,205
  • 9
  • 17
  • Thank you Sir. I also have found the following [link](https://greenido.files.wordpress.com/2013/07/git-local-remote.png?w=696&h=570), which backs your answer I guess. – KontrCode Apr 04 '18 at 07:09