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?

  • Unable to push file to git repository
  • Pod Error in Xcode “Id: framework not found Pods”
  • Git diff between current branch and master but not including unmerged master commits
  • how to rewrite history to remove executable bit in git
  • git-svn dcommiting a single git commit
  • Cloning git directly into web root public_html
  • Is there a way to integrate git with Jupyter and have a version control over the notebooks created?
  • Visual studio 2010 git extention manage remotes unable to connect
  • Remove a directory permanently from git
  • Gitolite on Ubuntu: No adminkey given
  • How do I delete a local repository in git?
  • git diff with interleaved lines
  • 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.

    Preparations.

    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.