Difference between revisions of "Git Fundamentals"
(Initial page creation) |
|||
| Line 15: | Line 15: | ||
=== Creating a Repo === | === Creating a Repo === | ||
Once Git is installed, use the command below to begin with creating a repository: | Once Git is installed, use the command below to begin with creating a repository: | ||
| − | |||
<nowiki> | <nowiki> | ||
gh repo create | gh repo create | ||
| Line 32: | Line 31: | ||
After the command has finished, run the below to initialize the repo:; | After the command has finished, run the below to initialize the repo:; | ||
| − | |||
<nowiki> | <nowiki> | ||
git init | git init | ||
| Line 38: | Line 36: | ||
Next the repo will need the account information of the user operating within this repo, to use as the author of changes being staged, committed, and pushed from this machine: | Next the repo will need the account information of the user operating within this repo, to use as the author of changes being staged, committed, and pushed from this machine: | ||
| − | |||
<nowiki> | <nowiki> | ||
git config --global user.email YOUR_EMAIL | git config --global user.email YOUR_EMAIL | ||
| Line 58: | Line 55: | ||
</nowiki> | </nowiki> | ||
| + | This will ADD all specified files if files/directories are provided, or will ADD the entire local directory if none are provided. | ||
| + | |||
| + | |||
| + | === Removing Files/Directories from Staging === | ||
And to REMOVE files from 'Staging' so they will NOT be committed: | And to REMOVE files from 'Staging' so they will NOT be committed: | ||
<nowiki> | <nowiki> | ||
git rm [FILENAME/DIRECTORY] | git rm [FILENAME/DIRECTORY] | ||
</nowiki> | </nowiki> | ||
| + | |||
| + | This will REMOVE all specified files if files/directories are provided, or will REMOVE the entire local directory if none are provided. | ||
| + | |||
To check the status of the files in the repo, compared to those in the online repo: | To check the status of the files in the repo, compared to those in the online repo: | ||
| Line 75: | Line 79: | ||
This will add/remove the entire list of staged files/directories to "Committed', along with a comment that will be visible. | This will add/remove the entire list of staged files/directories to "Committed', along with a comment that will be visible. | ||
| + | |||
=== Pushing Commits to GitHub === | === Pushing Commits to GitHub === | ||
Revision as of 06:14, 30 May 2024
Installing Git Packages
Git can be installed via the CLI on just about any Linux Distribution. Below are some examples of how to do so:
Fedora/RHEL/CentOS
sudo dnf install git
Ubuntu/Debian
sudo apt-get install git
Creating a Repo
Once Git is installed, use the command below to begin with creating a repository:
gh repo create
Follow the prompts of the command to continue creating and configuring the repository.
The prompts will likely walk-through/request the following:
-- Repo Name -- Repo Description -- Visibility settings for the repo (Public, Private, Internal) -- README file creation -- Creation of a .gitignore file (more on this specifically below) -- Deciding on a license (What other users are able to do with the code within your repo, i.e. GPLv3) -- Should the repo be cloned locally
After the command has finished, run the below to initialize the repo:;
git init
Next the repo will need the account information of the user operating within this repo, to use as the author of changes being staged, committed, and pushed from this machine:
git config --global user.email YOUR_EMAIL i.e. git config --global user.email first.last@domain.com
OR
git config --user.name YOUR_USERNAME i.e. git config --global user.name CoolGuyBob123
Adding Files/Directories to Staging
To ADD files to 'Staging' prior to committing them to the online repo:
git add [FILENAME/DIRECTORY]
This will ADD all specified files if files/directories are provided, or will ADD the entire local directory if none are provided.
Removing Files/Directories from Staging
And to REMOVE files from 'Staging' so they will NOT be committed:
git rm [FILENAME/DIRECTORY]
This will REMOVE all specified files if files/directories are provided, or will REMOVE the entire local directory if none are provided.
To check the status of the files in the repo, compared to those in the online repo:
git status
Committing Files/Directories
To add the files from 'Staging' to 'Committed':
git commit -m "INSERT COMMENT DESCRIBING THE CHANGES BEING COMMITTED"
This will add/remove the entire list of staged files/directories to "Committed', along with a comment that will be visible.
Pushing Commits to GitHub
To push the 'Committed' changes to the online repo, along with their respective comments:
git push