You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setup your git user name and email address:
git config --global user.name "John Doe" and
git config --global user.email johndoe@example.com (and optionally the
preferred text editor of git git config --global core.editor vim)
initialize the git repository using git init <directory>. Want a better
terminal experience? Try Oh My Zsh or
Oh My Bash!
use git status in order to see what you have currently in your git
repository
add the 3 text files using git add <filenames>
check the status of your repository with git status. Try to understand
the status output.
use git rm --cached <file names> as indicated in the status output
(or git reset <file names>) unstage the changes
stage the changes again, using git add <file names>
use git commit to save the files into a commit. A text editor will open
and you need to write a short commit message (e.g. "Initial commit"). Save
the text file and exit the editor when you are done to finish the commit.
now make some changes to the files. (e.g. delete some content)
try out the command git diff. What do you see?
Stage and commit again
use git log to get the name of the first commit
go back to the first version using git checkout <commit name>
check that you are seeing the first commit; check your current position in
the commit history through git log --all
go back to the latest commit using git checkout main (or
git checkout master, depending on the name of your default branch).
(for the adventurous: use git reset --hard <commit name> to return the
HEAD to the first commit. Why should this be avoided if possible?)
use git rm to remove the 3 text files
write a music album review, or choose a review from
Wikipedia, from
BBC Music Reviews, or from any other
source licensed by Creative Commons
(Please, don't use copyrighted material!)
make some changes to the review (personalize it!); commit the changed text;
this commit will be the base for the following parts.
1.2 You should have learned
how to create the local repository (init)
how to update the local repository (staging, committing, reset)
how to inspect the local repository (log, diff, show)
look at index.html with your web browser (note: you may need to enable
local file access for your browser. Instructions
here)
commit all files
make a new branch using git branch <branch name>. Checkout if the branch
exists with git branch and then git checkout <branch name> to move to it.
use git mv to put your album review file into the corresponding subfolder
as articles/example.md. This will overwrite the default article.
look again at index.html with your browser and see if your article shows up.
commit all the changes
Markdown-ize your article (if you don't know what's Markdown and/or how
to use it, please visit this page);
use git mv articles/example.md articles/<your_article>.md to give
a more appropriate name of your choice.
edit index.html to change the name of the article file.
commit these changes
do further edits to <your_article>.md, add one ore more images
commit the final version
switch back to the main (or master) branch; create a README.md file;
make a few more commits
use "Git Graph"
with Visual Studio Code or git log --all --graph --decorate in the
terminal to visualize the git graph structure. Other possible GUI are
gitk, GitUp on Mac, or
ungit on all platforms
(other clients are listed here)
create an ssh key using ssh-keygen and upload the key to GitHub
create a new repository on GitHub
use git add remote to add the remote repository to your repository (follow
the GitHub help when you create the repository)
use git push to push your commits to the remote (you get help with
git push --help)
edit the file README.md using the GitHub online interface
use git pull to download and merge the new version into the local repository
modify again the file README.md using the GitHub online interface
use git fetch to download remote commits
type git status. What are you seeing? Try to understand that git pull is
a combination of git fetch and git merge (or git rebase)
make a local commit and a remote commit using the GitHub interface, so that
the local and remote repository diverge. Try git push and see what happens
do again git fetch followed by git merge: look at the Git Graph
redo step "10" (local and remote commit), but now do git fetch followed by
git rebase: what is the difference between merge and rebase?
go one folder down from your repository
use git clone --bare to make a local clone of the repository. What is
a bare repository?
add the second local repository as remote local. Open the file
.git/config to see and change the remotes.
make a change, commit, and use git push local main (or
git push local master) to update the local repository
3.2 You should have learned
how to add a remote repository
how to synchronize (pull, fetch, push, merge, rebase) with the
remote repository
integrate your article into the billboard and commit to the new branch
push the modified billboard branch to your GitHub repository fork
add the main repository as a remote with name upstream to the local
repository. Checkout the file .git/config after you have done it. What
is the difference between origin and upstream?
open a pull request using the GitHub web interface to include your changes
in the main repository
reply to the comments of the repository managers and fix conflicts on
your local computer by committing and pushing new versions to your GitHub
fork's branch.
4.2 Advanced
Try to push from the local main (or master) to a different remote branch
with git push origin main:new_branch (or
git push origin master:new_branch).
4.3 You should have learned
how to use git to interact with a repository hosted on GitHub
how to work on foreign repositories using forks and pull requests