GitHub is a web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.
How to setup Git and GitHub
Download and install the latest version of GitHub
Desktop. This will automatically install Git and keep it up-to-date for you.
https://help.github.com/articles/set-up-git/
Introduce yourself to Git
- On your computer, open the Git Shell application.
- Enter these lines (with appropriate changes): git config –global user. name “John Smith” git config –global user.email [email protected]
- You only need to do this once
- If you want to use a different name/email address for a particular project,
- you can change it for just that project cd to the project directory Use the above commands, but leave out the –global.
The repository
Your top-level working directory contains everything about your project The working directory probably contains many subdirectories—source code, binaries, documentation, data files, etc.
- One of these subdirectories, named .git, is your repository At any time, you can take a “snapshot” of everything (or selected things) in your project directory and put it in your repository.
- This “snapshot” is called a commit object
- The commit object contains (1) a set of files, (2) references to the “parents” of the commit object, and (3) a unique “SHA1” name
- Commit objects do not require huge amounts of memory You can work as much as you like in your working directory, but the repository isn’t updated until you commit something.
init and the .git repository
- When you said git init in your project directory, or when you cloned an existing project,
- you created a repository The repository is a subdirectory named .git containing various files The dot indicates a “hidden” directory
- You do not work directly with the contents of that directory; various git commands do that for you.
Making commits
- You do your work in your project directory, as usual,
- If you create new files and/or folders, they are not tracked by Git unless you ask it to do so git add newFile1 newFolder1 newFolder2 newFile2
- Committing makes a “snapshot” of everything being tracked into your repository A message telling what you have done is required git commit –m “Uncrevulated the conundrum bar” git commit This version opens an editor for you the enter the message To finish, save and quit the editor.
- Format of the commit message One line containing the complete summary If more than one line, the second line must be blank.
Commits and graphs
- A commit is when you tell git that a change (or addition) you have made is ready to be included in the project
- When you commit your change to git, it creates a commit object
- A commit object represents the complete state of the project, including all the files in the project The very first commit object has no “parents”
- Usually, you take some commit object, make some changes, and create a new commit object; the original commit object is the parent of the new commit object
- Hence, most commit objects have a single parent You can also merge two commit objects to form a new one
- The new commit object has two parents Hence commit objects form a directed graph Git is all about using and manipulating this graph
Commit messages
- In git, “Commits are cheap.” Do them often.
- When you commit, you must provide a one-line message stating what you have done Terrible message:
- “Fixed a bunch of things” Better message:
- “Corrected the calculation of median scores”
- Commit messages can be very helpful,
- to yourself as well as to your team members You can’t say much in one line, so commit often
Typical workflow
- git status
- See what Git thinks is going on Use this frequently!
- Work on your files
- git add your edit files git commit –m “What I did”
Keeping it simple If you: Make sure you are current with the central repository Make some improvements to your code Update the central repository before anyone else does Then you don’t have to worry about resolving conflicts or working with multiple branches All the complexity in git comes from dealing with these Therefore: Make sure you are up-to-date before starting to work Commit and update the central repository frequently If you need help: https://help.github.com/
Introduce yourself to GitHub Register on GitHub
Authenticating to GitHub Desktop
https://help.github.com/desktop/guides/gettingstarted/authenticating-to-github/
Configuring Git for GitHub Desktop https://help.github.com/desktop/guides/gettingstarted/configuring-git-for-github-desktop/
Create or add a repository to GitHub Create a new repository on GitHub
https://help.github.com/articles/create-a-repo/
From GitHub Desktop, then Publish to GitHub
Remember to Publish, otherwise, your repository would not appear on the GitHub website.
Commit your changes on GitHub From GitHub Website https://help.github.com/articles/create-a-repo/
From GitHub Desktop https://help.github.com/desktop/guides/contributing/committingand-reviewing-changes-to-your-project/
Creating a branch for your work A branch is a parallel version of the main line of development in the repository, or the default branch (usually master). Use branches to Develop features Fix bugs Safely experiment with new ideas From the GitHub Website
https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
From the GitHub Desktop
https://help.github.com/desktop/guides/contributing/creating-a-branch-for-your-work/