Information worth remembering

User Tools

Site Tools


using_git_and_github

Using Git and GitHub

Below are some things you'll need:

I have some basic notes on Git here and on GitHub here. Check them out to refresh yourself on some key commands and features.

If you don't yet have a repository on GitHub, create one then do the following:

  1. Click the Clone or Download
  2. then copy the URI shown on GitHub (make sure it says Use HTTPS)
  3. On the local computer, from the console, make sure you are in the folder where you want to establish the local repository; and that you know where all the code that needs to be uploaded to GitHub is located.
  4. From the console type “git clone <paste what was copied>” then press enter
  5. This initialize a git repository for posting and synching with GitHub.
  6. NOW copy all your code you wish to start with for our project into that newly created folder from Git/GitHub.
  7. Change directory to that project folder.
  8. If you are satisfied with the current source, you now must issue the command: git status to show untracked files
  9. Now issue the command git add . to begin tracking all the files there. To see that they are being track, type git status
  10. To commit the changes to the local repository, issue the command git commit -m “message”
  11. Finally, you need to push it up to the GitHub repository using the command git push.

From this point forward, you can work locally on your computer to make changes to your code. But if you are collaborating with another developer who could be changing the same set of files, you need to do certain things to ensure you have the latest GitHub-posted code.

  • The first thing you should always do assuming you have already cloned the repository in the past is to issue the command git pull; this will pull down the latest versions of files from GitHub.
  • Make you changes
  • Do git commit -m “message”
  • Do git push

In reality, if you have many people working on code, it best to build new features on your own branch and not on the master branch. This way the main branch isn't screwed up with conflicting changes from 2 or more developers.

Creating Branches

  • To see what branches exist and which you are on, issue command git branch
  • To create a new branch, issue command git branch <newBranch>
  • To move to that branch, issue command git checkout <newBranch>
  • From this point, you can make changes and commits as before, then push the changes to GitHub. These changes will be show up on a new branch.
  • On GitHub, you can issue a pull request. The person reviewing can then merge the pull request to the master branch.
  • The other branch can then be deleted.

Contributing to Open Source Projects

To learn more about git and github, it's best to participate in an open source project.

In general, once you find the open source project, you'll want to FORK it. Once you've forked it, you'll have a copy of the project in our own repository. From here you can clone the repository to you local computer.

using_git_and_github.txt · Last modified: 2020/09/22 07:59 by admin