Skip to content

Tutorial 2: Using a Cloned Repository

Numeri edited this page Sep 13, 2015 · 1 revision

#Using a Cloned Repository Make sure you've read Cloning a Repository, then follow these steps:

##Getting Ready

  1. Open the Git Shell.
    On Windows, this is a shortcut on the desktop. On Linux, open the terminal.

  2. Navigate to repository's folder.
    For example:
    cd PATH_TO_REPOSITORY\REPOSITORY_NAME

    Be sure to replace PATH_TO_REPOSITORY and REPOSITORY_NAME with the actual path and name!

    If this step is an issue, consider asking a mentor or team member more experienced with the command line.

  3. Update your local copy.
    You need to be sure that the files on your computer match the online repository's files.
    Run the command:
    git pull
    This will "pull" the current version of files from <github.com> down to your cloned copy.

##Do work

  1. Edit any files you want.
    After editing the files, use this command to tell git what you updated:
    git add FILENAME
    This needs to be done for any files you create, as well.

##Update GitHub

  1. Commit the files.
    This tells git that you are 'committing' the changes to the files, but it doesn't update the online repository yet! It also allows git to keep a history of changes, so that we can revert to any version of a file.
    To commit a file, use the command:
    git commit FILENAME
    To commit every file, whether modified or not, use:
    git commit -a

    Note that this will change the description of the latest change that appears for files for ALL the files.

    To commit a file, and complete step 6 at the same time, use:
    git commit FILENAME -m MESSAGE
    See step 6 for more information.

  2. Describe your changes.
    You have to explain what you've changed, so that all the contributers can easily see the purpose behind changes. After running git commit, a text file will appear - enter a description of your changes, save the file, and exit the editor. As an alternative, use the -m MESSAGE flag described in step 5 to write the message without a text editor appearing.
    A good description might be:

Added new tutorials for using GitHub with the command line and seperated tutorials into folders.

  1. Push your clone to the repository.
    Pushing your clone, or local copy, to the online GitHub repository, will update the online repository to match your changes.

    Note that if anyone has changed the repository since you updated your clone, You will overwrite their changes!

    Make sure that you've updated recently to ensure that you don't do that! In cases where multiple people are actively editing the same repository, see Tutorial 3: Branches. This will be the case for most code, but unlikely for this repository, Reference.
    If you update after changing files, you will lose those files, so if you need to, backup your changes in a different folder, update your local copy, and replace the changed files.
    Now, to update the actual repository on GitHub, use the command:
    git push

That's all that there is to using a clone of a GitHub repository! But be sure that you know what you're supposed to be doing: a lot of the work with Techbrick's repositories on GitHub should be done using branches, rather than clones (see Tutorial 3: Branches). Good luck!

Clone this wiki locally