1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

updated git blog post

This commit is contained in:
2015-10-27 09:16:43 -05:00
parent f1006ab8b4
commit 77e382c5f1

View File

@@ -39,7 +39,7 @@
<br>
<code>$ git config --global user.email johndoe@example.com</code>
<p>Now that you have initialized your git repositor, you can start on your project and begin adding files. When you wish to save your files to the repository, you must first add all of the changes. YOU MUST ADD CHANGES BEFORE YOU COMMIT!! I have commited and pushed without adding changes multiple times before so do not forget!
<p>Now that you have initialized your git repository, you can start on your project and begin adding files. When you wish to save your files to the repository, you must first add all of the changes. YOU MUST ADD CHANGES BEFORE YOU COMMIT!! I have commited and pushed without adding changes multiple times before so do not forget!
</p>
<code>$ git add -A</code>
@@ -85,4 +85,40 @@
<p>This is just a beginner guide on how to use git for the first time. There are still many other things that git has to offer, but these are the basic commands to get you started and using git.
</p>
<h3>Edit 10/27/15: More information on Git</h3>
<p>I would like to discuss a few more things about git that I have learned and become familiar with. I am hosting this website on an Ubuntu VPS from Digital Ocean and I rely heavily on git to update and make changes. I've recently added a new "working" branch to my repository. This makes it easier to work on changes while not breaking the master branch. Another branch can be made on github and you can base it off another branch. I started a "working" branch and copied the master branch.</p>
<code>$git checkout working</code>
<p>Now, after cloning my repository I can switch to my new working branch with the checkout command. Keep in mind that if I was working on my master branch with uncommited changes, I cannot checkout to another branch without commiting current changes to the master branch. After making new changes to my new "working" branch I can add, commit, and push them to Github. If and when I want to update my master branch I can checkout to my master branch, merge changes with "working" and push changes to Github. The master branch should then be up to date with the "working" branch.</p>
<code>$git add -A</code>
<br>
<code>$git commit -m "commit message"</code>
<br>
<code>$git push origin working</code>
<br>
<code>$git checkout master</code>
<br>
<code>$git merge working</code>
<br>
<code>$git push origin master</code>
<br>
<p>At any time you can check to see which branch you are working on and if any files have been updated/are ready to commit by using the status command</p>
<code>$git status</code>
<br>
<p>Now that my changes with "working" are updated on "master" I can pull the changes to my server on Digital Ocean. I sometimes have to log into my server and make minor updates to the code. This can cause merge conflicts with git and I may be unable to pull the master branch. To resolve this issue I must reset the master branch so that I can pull new changes.</p>
<code>$git reset --hard</code>
<br>
<code>$git pull</code>
<br>
<p>This will reset the branch to the last commit and get rid of any uncommited changes. Only do this if you have not made changes that you want to save. Because it is running on my server, I want to overwrite any changes anyway.</p>
<p>These are a few more git commands that I have learned since working on this project. As I become more familiar with git I will continue to update this post</p>
</div>