Created
July 4, 2013 08:15
-
-
Save tamboer/5925853 to your computer and use it in GitHub Desktop.
git create a new repo and push to github
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Step 1: Create the README file | |
| In the prompt, type the following code: | |
| mkdir ~/Hello-World | |
| # Creates a directory for your project called "Hello-World" in your user directory | |
| cd ~/Hello-World | |
| # Changes the current working directory to your newly created directory | |
| git init | |
| # Sets up the necessary Git files | |
| # Initialized empty Git repository in /Users/you/Hello-World/.git/ | |
| touch README | |
| # Creates a file called "README" in your Hello-World directory | |
| Open the new README file found in your Hello-World directory in a text editor and add the text "Hello World!" When you are finished, save and close the file. | |
| Step 2: Commit your README | |
| Now that you have your README set up, it's time to commit it. A commit is essentially a snapshot of all the files in your project at a particular point in time. In the prompt, type the following code: | |
| More about commits | |
| git add README | |
| # Stages your README file, adding it to the list of files to be committed | |
| git commit -m 'first commit' | |
| # Commits your files, adding the message "first commit" | |
| Step 3: Push your commit | |
| So far everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repository and push your commits to it: | |
| More about remotes | |
| git remote add origin https://github.com/username/Hello-World.git | |
| # NOT sure if we can use this url too -->> git@github.com:username/gitname.git | |
| # Creates a remote named "origin" pointing at your GitHub repository | |
| git push origin master | |
| # Sends your commits in the "master" branch to GitHub | |
| Now if you look at your repository on GitHub, you will see your README has been added to it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment