How do I create a GitHub repository from an existing directory?
Category:
technology and computing
web hosting
- Create a new repository on GitHub.
- Open TerminalTerminalGit Bash.
- Change the current working directory to your local project.
- Initialize the local directory as a Git repository.
- Add the files in your new local repository.
- Commit the files that you've staged in your local repository.
Beside this, how do I create a Git repository from an existing folder?
A new repo from an existing project
- Go into the directory containing the project.
- Type git init .
- Type git add to add all of the relevant files.
- You'll probably want to create a . gitignore file right away, to indicate all of the files you don't want to track. Use git add . gitignore , too.
- Type git commit .
- Then rename the repo with upstream using: git remote rename origin upstream.
- Then add your repository url to your remote using: git remote add origin <url>
- Then push the changes to your remote repo using: git push origin master.
- To get updated and to pull the changes you can do:
Consequently, how do I push to an existing GitHub repository?
From your terminal and assuming Git is already installed on your computer, run the following commands after navigating to folder you would like to add:
- Initialize the Git Repo. git init.
- Add the files to Git index. git add -A.
- Commit Added Files.
- Add new remote origin (in this case, GitHub)
- Push to GitHub.
- All together.
To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A remote name, for example, “origin” A remote URL, which you can find on the Source sub-tab of your Git repo.