A tutorial to setup a basic github (with markdown)
- I hope you understand directory trees.
- And the meaning of $HOME $PWD (if not,try
echo $HOMEorecho $PWD) - Remember
.is synonymous to$PWD
-
Clone the past index of this repository to your local directory, say $HOME
git clone https://github.com/shouldsee/HelloWorldRepo $HOME/HelloWorldRepo #### The traget directory can be omiited to just $HOME (or empty which means $PWD) #### Or try to be humourous: git clone https://github.com/shouldsee/HelloWorldRepo mySecretion -
Download your favourite meme in the format of
.jpgor.pngor.svg- And save it as '$HOME/mySecretion/someMeme.jpg'
- if you are feeling lazy, do
wget https://i.imgflip.com/12zidp.jpg -O $HOME/mySecretion/someMeme.jpg
-
Create a markdown file
$HOME/myMeme.md- Paste the following text into
$HOME/myMeme.md
### This is some lovely meme  Unless you downloaded you image from [Imgur](https://imgur.com/), you probably should not find the image above on Imgur. But you can calculate its probability easily with: $$ P(\text{imgur}) =\sum_{\text{images}}{ P(\text{imgur},\text{images}) } $$ - Paste the following text into
-
If you are good at markdown, play some tricks with
README.md -
Now add/stage your changes using
git add- You can specify files explicitly
git add myMeme.md someMeme.jpg - Or to be lazy just do
git add $PWDorgit add .to add all modifications to next commit - Make sure files are added by doing
git status
- You can specify files explicitly
-
Once you are sure all modifications are added, record these by making a COMMIT!
git commit -m i_dont_know_what_im_doing- or just do
git commitand enter your message in the new text editor window. You have to save a non-empty COMMIT_MSG in order to proceed
-
If you commit is successful, git should have recorded your changes and you can continue to make next commit
- Optional:
- You can jump back one commit temporarily with
git checkout HEAD~1 - You can jump to the newest commit with
git checkout HEAD
- You can jump back one commit temporarily with
- Optional:
So far you have made a local commit, that is not visible to others unless you email the directory to them or somehow exchanged the index in .git/ . Luckily, there are many public servers that host remote copy of a repository.
- To check what remotes are visible to your current git repo, do
git remote -v- You should see that
origin https://github.com/shouldsee/HelloWorldRepois listed. Hence it's known asorigin
- You should see that
- To check what branches are visible, do
git branch -v- You should see
* masteris your current branch
- You should see
- Now try
git push origin master, which would push themasterbranch tooriginremote.- And you would enter username and password to attempt this push.
- And you would find yourself failed, since you are not authorised write permission of this repository.
- Okay, but we can always find another way.
- Open the remote (https://github.com/shouldsee/HelloWorldRepo) as a webpage.
- Click
Forkon the top-right corner - Login if required
- You will now obtain a remote fork of this repository, associated with a url (which you can read off in the URL bar, often in the form
https://github.com/{YOUR_GITHUB_USERNAME}/HelloWorldRepo)- now we are gonna do some magic to redirect the upstream to your new remote repository
git set-url origin https://github.com/{YOUR_GITHUB_USERNAME}/HelloWorldRepo(you will need to fill in this command before execution!!!)
- After redirect the
originto your newly forked repository, you can try to push the commit againgit push origin master- Enter github credential accordingly
- Works like a charm hopefully