- Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
- Open Git Bash. You can find the link here: https://git-scm.com/downloads if you have not installed git.
- Change the current working directory to your local project. cd /Users/admin/source/repos/
Initialize the local directory as a Git repository: “git init” . You should read up on the documentation of the initialization of https://git-scm.com/docs/git-init
You can either create a new repository (as in the example below) or initialize an existing directory as a git repository.
Once the repository is created or initialized you will see a hidden .git directory. This is all part of the mechanics of version control and the features of git.
The working directory of your git directory in this example is NewRepository. This will be whatever directory you created or initialized with git. If you right click on the directory you will see options to Git Gui or Git Bash (they both do the same thing just one is command line and the other is a GUI version).
Now you are going to have some files in this directory. That is kind of the point of using git. These can be programming files (code) or other types of files. You will be adding these files to your repository. This is the git add command and you will also want to know the use of this command https://git-scm.com/docs/git-add
git add . #adds all the files in the repo and stages them for commit.
You are now ready to commit the files to the repository. This is done with the git commit command. As with the other commands it is worthwhile to read the documentation to know what it does. https://git-scm.com/docs/git-commit
Now you can go into Github (you should have an account), create a new repository and either follow the instructions there or the instructions here – they are the same.
Now you will be able to push your information from your local git to the remote version at github. Congratulations you now have a code managed repository.
You can view your repositories in github
There are some commands you will want to know such as git remote, git push, git fetch