Changes

Using Github and Git for Code

491 bytes added, 14:22, 5 December 2013
updated with instructions about pulling in from remote repositories.
==Making Changes to Code==
* When starting to make changes, to avoid conflicts update your current repository by pulling in the remote branches (presumes branch named master and remote named origin):
<pre>git pull origin master</pre>
* To check the status of your repository enter:
<pre>git status</pre>
* To determine the current branches and the names of your remote repository:
<pre>git branch</pre>
<pre>git remote -v</pre>
* It is generally best practice to work on a branch for each improvement, then merge that back into a working master branch once you are finished.
* Create a branch. Each branch is a complete clean version of the code, and will not affect other branches. Pick a name that describes the changes you plan to make.
<pre>git branch [name of your new branch]</pre>
* Switch to that branch
<pre>git checkout [name of the branch you want to switch to]</pre>
* Make some changes to a file and save it (i use Notepad++ in windows and Gedit or vim in linux)
* Commit the changes. This saves those changes to your revision history. This is useful to find out when changes happened and to go back to when things were working. You want to commit often! Try to make the message useful, as in I did X to Y. Try not to do "changed stuff" or "fixed some mistakes"
<pre>git commit -m "This is the message describing the commit"</pre>
* Intermittently push those changes back to Github (especially if you are working on a couple of computers; this presumes that your remote is named origin, which is the default):
<pre>git push origin [name of your new branch]</pre>
* Once you are done working on a branch go back to your original branch (normally master) and pull in changes from your modified branch. Once its working, you can optionally delete the branch if you dont think you are going to need it in the future.
git branch -d [name of branch you want to delete]
</pre>
 
 
 
==Merging Changes Made in Other Branches==