This guide provides a step-by-step process for setting up a Git repository for your group assignment.
Only one person in the group needs to create the repository and the .gitignore
file.
Version Control Recommended
Setting up a Git repository is optional, but highly recommended for managing code collaboratively.
Installing Git
Ensure Git is installed on your system using:
git --version
If Git is installed, you’ll see output similar to:
git version x.xx.x
If you receive an error or no output, follow the steps below:
Install git using Homebrew:
brew install git
If you don't have Homebrew, first install it from brew.sh
Install git using the package manager included with your Linux distribution.
Download git from here.
Initializing Git in an Existing Project
Navigate to the Aegis Directory
Open a terminal and change into the Aegis directory
cd path/to/aegis/directory
Initialize the Git Repo
Initialize Git in the Aegis directory
git init
Create a New Repository
- Go to GitHub and log in.
- Click the "New" button to create a new repository.
- Enter a repository name, choose private for the visibility, and click "Create Repository".
- Go to Gitlab and log in with your IT account.
- Click the "+" button and then click "New project/repository".
- Create a blank project.
- Enter a project name, choose private for the visibility, and click "Create Project".
Add a Remote Repository
Link your aegis repository to the newly created remote repository.
git remote add origin https://github.com/yourusername/your-repo.git
Creating a .gitignore file
File Placement
The .gitignore
file must be in the root of your project to work correctly.
A .gitignore
file tells git which files to ignore.
Create the .gitignore file
Creating a file in the command line:
touch .gitignore
or you can use the file explorer.
Add the Following Content
client
.venv
venv
*__pycache__*
# Editor directories and files
.DS_Store
.vscode/*
!.vscode/extensions.json
.idea
*.suo *.ntvs*
*.njsproj
*.sln
*.sw?
Typical Repository Structure
Initial Commit and Push
Stage and Commit Files
git add .
git commit -m "Initial Commit"
Push to the Repository
git branch -M main
git push -u origin main
Cloning the Repository
After being added to the repository, the group members should clone the repository to their local machines.
git clone https://github.com/ownerusername/your-repo.git
Essential Git Workflow Commands
Collaboration best practices
Minimize merge conflicts and maintain smooth team collaboration by following these key Git workflow principles:
- Always pull changes before starting work to ensure you have the latest project state.
- Communicate with your team about who is working on specific files or features.
- Pull changes from the remote repository immediately before pushing your commits.
- Break your work into small commits that allow you to easily revert changes if something breaks. This provides a clear rollback path and reduces the risk of losing significant work.
Pull Latest Changes
git pull
Pushing Your Changes
git add .
git commit -m "Descriptive commit message"
git push
Checking Repository Status
git status
Additional Resources
- Git Official Documentation
- GitHub Desktop (alternative to command line)