Install git on your computer.
Windows Users install from https://git-scm.com/
Mac Users should have it already. Verify install by opening a terminal and typing git --version
and verify a version number is shown. If error, install from link above
Linux Users probably have it already. Verify install by opening a terminal and typing git --version
and verify a version number is shown. If error, try apt-get install git
or install via your system's package manager.
Required: Create an account here: https://github.com/
Optional: request the GitHub student pack here - free private repositories, credit for various web/software engineering tools and services: https://education.github.com/pack. If you used your student email to sign up for GitHub, you'll be approved faster; if you used a personal email you'll probably have to provide additional proof of student status.
Windows open the git bash application that installed with Git.
Mac and Linx open the terminal application
If you've done this before: navigate to a location where you'd like to store your code. Create a new directory called website
in the location of your choice, and cd into this directory.
If you haven't used the terminal before:
Windows
Type the following commands into the bash shell. If any give you error messages, stop and troubleshoot. Replace USERNAME with your starID if on a lab computer, or with your username on your own computer.
cd /c/Users
cd USERNAME
mkdir git_lab
cd git_lab
mkdir website
cd website
Mac/Linux
cd ~
mkdir git_lab
cd git_lab
mkdir website
cd website
You should now have a new directory called website
and the terminal should have the focus on this directory.
Type this command, to display the present working directory
pwd
The output should end with /website/
At this point, the commands for Windows/Git Bash and Mac, Linux shell/terminal are the same.
Type the following to set your name and email globally. Since these will end up being public on GitHub, suggest using just your first name, or initials, or nickname. And, you can make up an email address.
When you are working on a project for a company, you would use your real name and your company email address.
git config --global user.name "YOUR NAME HERE"
git config --global user.email make_up@an_email.com
Type the following to create a HTML page and a stylesheet
touch index.html
touch style.css
Open both of these files in your prefered text editor.
Enter the following in your index.html
<link rel='stylesheet' href='style.css'>
<h1>Hello, this is a new website</h1>
and the following in your style.css stylesheet
h1 : {
text-shadow: 0 0 5px #FF69B4
}
Save both of these files.
In your terminal, type the following
git init
You should see a message that includes Initialized empty Git repository in YOURDIRECTORY/website/.git/
git status
shows you the current status of your repository. Type
git status
The output will look something like this
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
style.css
nothing added to commit but untracked files present (use "git add" to track)
Type
git add .
This command will not show any output. In fact, most terminal commands don't have any output if they are successful. Now type
git status
Now the output will look like this,
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
new file: style.css
You've added your files to git's staging area, in preparation to make a commit.
Type this to make a commit.
git commit -m 'Set up index.html and linked the stylesheet'
The output will look something like this. The number 2ab8288 in the output below will probably be different on your computer.
[master (root-commit) 2ab8288] Set up index.html and linked the stylesheet
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
create mode 100644 style.css
Now type
git status
The output should be something like this,
On branch master
nothing to commit, working directory clean
Which means that there are no changes in your code since the last time you made a commit.
Type
git log
to see a list of commits.
Add colors Add image todo
status, add, commit, status, log
Add image todo
status, add, commit, status, log
make change
run git diff
observe change
status, add, commit, status, log
todo
todo
git remote add origin https:\\github.com\YOURUSERNAME\YOURREPO
git push -u origin master
todo
Turn on github pages
view page at TODO
With a partner
Pick one of your github repos
Add the other person as collaborator
Other person : pull first person's code
git clone URL
one of you is the designer. change the background color in the stylesheet one of you is the content creator. Add a new paragraph to the website saying "git is great!"
Both: add and commit and push
pull to get other persons's code
Repeat:
Add another paragraph add another style
Both: add and commit and push
pull to get other persons's code
verify you have the complete version of both of your work
Git is smart enough to merge two versions where different files, or different parts of the same file, have been changed. What if you both change the same line in the same way?
A: modify the line that says "Git is great!" to "Git is confusing" or "Git is awesome" or whatever. B: do the same, but modify it to your own opinion of Git.
A: add and commit and push B: add and commit and push. What happens?
This is a merge conflict. B, run
git pull
And open index.html. You'll see some extra text that git has added. Depending on your editor, there may be some extra flags or markers in this area. index.html will now contain A's work, and B's work, and some <<<<<<< and ======= and >>>>>>> markers. Spot your change, and the other person's change.
<<<<<<< HEAD
<p>git is super awesome!!! I could not be more excited!!!</P>
=======
<p>I have been instructed that I should like Git but I am confused about it at this point.</P>
>>>>>>> cb1abc6b345656a345b456bac234234acb
The last line, with the >>>>>> followed by the number, will have a different number in your project.
The top part is B's code. The bottom part is A's code.
B, please edit this part of code. Delete the lines starting with <<<<<< and >>>>>> and ====== Modify the file to combine both of your opinions into one line, perhaps as follows,
<p>git is super awesome although is confusing to start with.</P>
IRL the team leader would decide how best to fix the conflict - A's code, B's code, a combination of both.
B, save, git add, git commit, git push.
A, git pull.
Should both have latest version, with the conflict fixed