Create git repository for existing project?

After a close call with deleting a swift file, I noticed that I did not have create the project with it to create a git repository. Is there a way to have an existing project start a git repository? Or do I have to start a new project and move all of my code/files over?

  • Why would a line's SHA in a git blame view have a leading caret (^)?
  • Screwed up the master git branch… Can't figure out what I need to revert
  • What are possible scenarios why one should create a git commit in the past?
  • opposite of .gitignore file?
  • Case typo on path in msysgit
  • pdf-writer-1.1.8/lib/pdf/writer.rb:712: invalid multibyte char (US-ASCII)
  • Where is Heroku getting its RSA key from? It seems to be somewhere other than ~/.ssh/
  • Renaming RStudio project under version control
  • Error “duplicate entry names” while migrating existing repository data to LFS using git-lfs-migrate
  • Git WebHook (PHP) cannot access ruby environment, running jekyll as apache user
  • Use one “main project” as source for many projects: how to do it best with GitHub?
  • How do I reset all deleted files
  • One Solution collect form web for “Create git repository for existing project?”

    Yes, you can initiate a git repo for an existing project.
    There are several ways to initiate and manage a Git repository over an existing project.


    There are some files that are not subject to source control. Those are project files from your IDE, compiled classes and so on. To exclude them, get a .gitignore file and put it to the root directory of your project.

    Creating a Git repo with command-line tool

    go inside the project folder and create new git repository using:

    cd path/to/your/project
    git init

    Then add your files

    git add *

    and then commit

    git commit -am "Initial commit"

    if you need to push it to GitHub/BitBucket use

    git remote add origin remote [repository URL]

    and then

    git push origin master

    Creating a Git repo with a gui-based tool or IDE.

    You can as well use any gui-based tool. E.g., in IntelliJ IDEA use the menu [VCS] – [Import into version control] – [Create Git repository].

    If you are going to use GitHub, there’s a convenient GitHub client.

    Git Baby is a git and github fan, let's start git clone.