Public repo for software development infrastructure based on git, K3s, Docker
A basic guide on how developers can use Git:
Git Basics:
-
Install Git:
- Download and install Git from the official website: Git Downloads.
-
Configure Git:
- Set your username and email address using the following commands:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
- Set your username and email address using the following commands:
-
Create a New Repository:
- To start a new project or add version control to an existing project, navigate to the project's directory and run:
git init
- To start a new project or add version control to an existing project, navigate to the project's directory and run:
Working with Repositories:
-
Clone a Repository:
- To get a copy of an existing repository, use:
git clone <repository-url>
- To get a copy of an existing repository, use:
-
Check Repository Status:
- View the status of changes in your working directory with:
git status
- View the status of changes in your working directory with:
Making Changes:
-
Stage Changes:
- Add changes to the staging area before committing:
git add <file1> <file2> ...
- Add changes to the staging area before committing:
-
Commit Changes:
- Save staged changes to the repository:
git commit -m "Your commit message"
- Save staged changes to the repository:
Branching:
-
Create a Branch:
- Start a new branch for a feature or bug fix:
git branch <branch-name>
- Start a new branch for a feature or bug fix:
-
Switch Branches:
- Move to a different branch:
git checkout <branch-name>
- Move to a different branch:
Merging:
- Merge Changes:
- Combine changes from one branch into another:
git merge <branch-name>
- Combine changes from one branch into another:
Remote Repositories:
-
Add a Remote:
- Connect your local repository to a remote repository:
git remote add origin <remote-url>
- Connect your local repository to a remote repository:
-
Push Changes:
- Upload local changes to a remote repository:
git push -u origin <branch-name>
- Upload local changes to a remote repository:
-
Pull Changes:
- Update your local repository with changes from the remote repository:
git pull origin <branch-name>
- Update your local repository with changes from the remote repository:
Handling Conflicts:
- Resolve Conflicts:
- If conflicts arise during a merge, resolve them manually and then:
git add <conflicted-file> git commit
- If conflicts arise during a merge, resolve them manually and then:
History and Logs:
-
View Commit History:
- See a log of all commits:
git log
- See a log of all commits:
-
Differences:
- View changes between commits, branches, etc.:
git diff <source-branch> <target-branch>
- View changes between commits, branches, etc.:
This is a basic guide, and Git is a powerful tool with many features. Developers may need to refer to the official Git documentation for more advanced usage and troubleshooting: Git Documentation.