Creating a Repository for Our Website



In this post we will be creating a public repository for our website. We will make some updates locally, add, commit, and push our code changes up to the GitHub where the whole world can see it!

Step 1: Create the Repository on GitHub

Once you are logged into GitHub. Click on the “New Repository” button. First, give the repository a name. Then select either “Public” or “Private” depending on who should be able to see this repository. Check the “Initialize with README” checkbox and click “Create Repository”.

Now, on our repository home page, click on the “Clone or Download” button and copy the “Clone with SSH” link.

clone with ssh

Step 2: Command Line Git Commands

1. Open up the command line and use the following command to clone the repository that was just created in step 1. The git clone command will clone everything in our easycodeis repository from GitHub down to our localhost.

git clone git@github.com:jstolpe/easycodeis.git

2. Now, inside of our easycodeis folder run the git status command. This command will tell us how our local folder compares to what is on GitHub.

git status

3. Running “git status” in #2 should have told you everything is up to date. Now, lets add some files to the repository. I am adding an index.php file, css folder, and an assets folder. Once those files have been added inside of my easycodeis folder, I can add them on the command line. This will get them ready to commit.

git add --all

4. Run “git status” again (#3). We see our files are now in green which means they are ready to commit!

5. Commit the files. This will commit the files to our repository, but only locally.

git commit -m "initial code commit"

6. Push the files we have committed up to GitHub! This command is where our committed files in our local repository actually go up to GitHub. All we have to do is run our push command!

git push

Head over to GitHub and check out the repository. It should now be updated with the files we have added, along with our commit message in the commit log. We have successfully setup a repository for our website! A few tips I have would be to run git status, a lot. This way you can quickly check to see if anything locally differs from the repository. Also, run git pull before you begin working. This will make sure you have the latest and greatest code in the repository before starting in on a new feature. If you do not do a git pull before starting a new feature, and there have been many other developers who have committed lots of updates, you are not starting with the most recent, up to date repository. In this case, you run the risk of many merge conflicts when you are ready to commit your code.

Links

YouTube Video

Code on GitHub

That is going to do it for this post! Leave any comments/questions/concerns below and thanks for stopping by the blog!

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *