Git account and Project upload
Git account and Project upload
Install Git:
Windows:
o Download the Git for Windows installer from the official Git website (git-
scm.com).
o Run the installer and follow the on-screen instructions. You can generally
accept the default settings.
Git --version
After installation, you need to configure your username and email address. Git uses
this information to identify your commits.
Open your terminal or command prompt and run the following commands, replacing
the example values with your own:
o git config --global user.name "Your Name"
o git config --global user.email "[email protected]"
o The --global option sets these configurations for all Git repositories on your
system.
1. Click the "+" icon in the top right corner and select "New repository."
2. Give your repository a name (e.g., "my-django-project").
3. You can add a description if you like.
4. Choose whether to make the repository public or private.
5. Do not initialize the repository with a README, .gitignore, or license at this
stage. We'll handle these locally.
6. Click "Create repository."
cd /path/to/your/django/project
git init
A .gitignore file specifies files and directories that Git should ignore. This is crucial
for excluding sensitive information and unnecessary files from your repository.
Create a .gitignore file in your project's root directory:
touch .gitignore
Open the .gitignore file in a text editor and add the following (or similar) content:
Code snippet
*.pyc
__pycache__/
db.sqlite3
/static
/media
.env
*.log
venv/
myproject/settings.py # If you have sensitive info directly in
settings.py. better to use .env
Adjust this list based on your project's specific needs. For example, if you're using a different
database or have custom log files, add them to .gitignore.
4. Add and Commit Your Files:
git add .
Copy the remote repository URL from your GitHub repository page. It will look
something like this:
https://github.com/your-username/my-django-project.git
If you're using a branch other than master (e.g., main), replace master with your branch
name. The -u flag sets the upstream branch, so you can simply use git push in the future.
7. Verify on GitHub:
Configuring Git on your local machine is essential for effectively using version control.
Here's a breakdown of the key steps: