Skip to content

Instantly share code, notes, and snippets.

@develax
Last active October 26, 2018 14:19
Show Gist options
  • Save develax/e88c88d3212e51194e4138915f94c2a6 to your computer and use it in GitHub Desktop.
Save develax/e88c88d3212e51194e4138915f94c2a6 to your computer and use it in GitHub Desktop.
Adding a new project to Git (on Windows) from scratch

Adding a new project to Git (on Windows) from scratch

Setup Git and commit the project files

  1. Go to https://git-scm.com download the installer and install it leaving everything by default (you can check that it was successful via windows console with the git --version command).
  2. Run windows console via cmd command and go to the project root folder (or run it from that folder).
  3. Execute the git init command (it will create the ".git" hidden folder inside your project folder).
  4. Run the git status command to check that nothing has been added to Git yet.
  5. To make some files (or folders) be tracked by Git run the git add filename.fileext command (you can run git status after to check whether the file has been added and ready to be commited).
  6. Add to the project root folder a new file called .gitignore. It should be a text file. Open it and write to it all files and folder (each one on a new line) you want to be ignored by Git. For example: node_modules/
  7. Add the .gitignore file to Git too (see step 5).
  8. Commit all the files you've added using the git commit -m "Put you comment in here". After that any changes to these files will be tracked by Git.

Generating SSH Key

  1. Open Git Bash (not windows console).
  2. Check if you already have an existing SSH key: ls -al ~/.ssh (if it exists then skip this process).
  3. Run ssh-keygen -t rsa -b 4096 -C '[email protected]'. Press enter (by default) for all questions.

Starting the SSH agent

  1. Open Git Bash.
  2. Run the command eval "$(ssh-agent -s)". (This will start up the SSH agent program and it will also print the process ID to confirm it is indeed running)
  3. Tell the SSH agent the folder path where the private key lives: ssh-add ~/.ssh/id_rsa. (expected message: "Idenity added..")

Configure GitHub account

  1. Go to github.com -> Account menu -> Settings -> SSH and GPG keys and add your SSH key in there.
  2. In order to test your connection run the ssh -T [email protected] command. It should say The authenticity of host 'github.com (192.30.253.113)' can't be established.. It's ok, enter yes. If successful, you will see the message starting with "Warning: Permanently added ...".
  3. Go to the GitHum home page and create a new repository there.
  4. Assosiante your new prepository with your local project by running the git remote add origin https://github.com/YouUserName/you-repository-name.gitcommand from your project directory (via windows console).
  5. Push your sources to the GitHum repository: git push -u origin master.
@develax
Copy link
Author

develax commented Sep 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment