HowTo - GIT & GitHub

From Da Nerd Mage Wiki
Revision as of 17:23, 23 September 2022 by Tinker (talk | contribs) (Created page with "<div>==GitHub==</div><div><br></div><div>* Required tools:</div><div>** <code>sudo apt install git</code></div><div>** [https://github.com/cli/cli/blob/trunk/docs/install_linux.md Installing gh on Linux and BSD]</div><div>***<code>curl -fsSL <nowiki>https://cli.github.com/packages/githubcli-archive-keyring.gpg</nowiki> {{!}} sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg</code></div><div>***<code>sudo chmod go+r /us...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
==GitHub==

* Required tools:
** <code>sudo apt install git</code>
** Installing gh on Linux and BSD
***<code>curl -fsSL <nowiki>https://cli.github.com/packages/githubcli-archive-keyring.gpg</nowiki> | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg</code>
***<code>sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg</code>
***<code>echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] <nowiki>https://cli.github.com/packages</nowiki> stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null</code>
***<code>sudo apt update</code>
***<code>sudo apt install gh</code>
* Basic writing and formatting syntax (For your .md files)

===Creating a repository from scratch===
(Based on a local project folder)

<syntaxhighlight lang="bash">
cd ~/Projects/Nuggit                       # Location of existing local folder
vi README.md .gitignore                    # Create these useful files
git init                                   # 
git add README.md .gitignore               # 
git commit -m "first commit"               # 
git branch -M main                         # 
gh repo create Nuggit --source=. --private # Creating the actual Repo on GitHub
git push -u origin main                    # Push the folder layout & initial files

git add *                                  # Add in the rest of the project
git commit -m "second commit"
git push -u origin main                    # & push it...
</syntaxhighlight>

===Pulling down a repository for local work===
(Into a local project folder)

<syntaxhighlight lang="bash">
cd ~/Projects                       # Location to create local folder
gh repo clone REPONAME
</syntaxhighlight>

===Uploading Changes to a Repository===
(doesn't remove deleted files...)

<syntaxhighlight lang="bash">
cd PROJECTFOLDER
git add *
git commit -m "MESSAGE"
git push 
</syntaxhighlight>

===Removing file(s) from a repository===

<syntaxhighlight lang="bash">
cd PROJECTFOLDER
git rm FILESTOBEREMOVED
git commit -m "MESSAGE"
git push
</syntaxhighlight>