Setting Up a Git Repository

Use command-line commands to set up a Git repository for an existing project.

To set up a Git repository
  1. Use the cd command to switch to your project directory, making it the current working directory.

  2. Enter git init to create an empty repository.

  3. Enter git add . to copy your project files into the repository.

  4. Enter git commit -m "Initial commit" to commit all the files.

// Step 1
$ cd /Users/me/sample_code/Sketch
// Step 2
$ git init
Initialized empty Git repository in /Users/me/sample_code/Sketch/.git/
// Step 3
$ git add .
// Step 4
$ git commit -m "Initial commit"
[master (root-commit) 173067e] Initial commit
 74 files changed, 10198 insertions(+)
 create mode 100644 .DS_Store
 create mode 100644 Arrow.tiff
 create mode 100644 Circle.tiff
 create mode 100644 Cross.tiff
 create mode 100644 Draw2App.icns
 create mode 100644 Draw2File.icns
 create mode 100644 English.lproj/Draw2.nib/classes.nib
 create mode 100644 Sketch.xcodeproj/xcuserdata/ernest.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
 create mode 100644 Sketch.xcodeproj/xcuserdata/ernest.xcuserdatad/xcschemes/Sketch.xcscheme
 create mode 100644 Sketch.xcodeproj/xcuserdata/ernest.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 TextGraphic.tiff

To set up a repository for an existing project, you have to use the command-line shell implemented by the Terminal utility app.