Idiots guide to getting started in git

By | December 7, 2017

A new repo from scratch

  • Create a directory to contain the project.
  • Go into the new directory.
  • Type git init.
  • Write some code.
  • Type git add to add the files
  • Type git commit.

A new repo from an existing project

Say you’ve got an existing project that you want to start tracking with git.

  • Go into the directory containing the project.
  • Type git init.
  • You’ll probably want to create a .gitignore file right away, to indicate all of the files you don’t want to track.
  • Type git add --all to add all of the relevant files
  • Type git status to review files that have been added to version control.
  • Type git commit.

Adding remote repository

You’ve now got a local git repository. You can use git locally, like that, if you want. But if you want the project to be available remotely, do the following.

Note, you’ll find the repo tends to default to being called origin, I’ve called mine bitbucket so its obvious to me which service I’ve working with.

  • Create a repository on bitbucket.org or github etc etc
  • git remote add bitbucket https://sscotter@bitbucket.org/sscotter/rsdnsapi.git
  • To update remote repo simply do a git push bitbucket
  • To update local repo simply do a git pull bitbucket
Category: Git