Git is a powerful tool for version control and deployment. Here's a guide to help you deploy your projects using Git:

🛠️ Basic Steps

  1. Initialize a Git Repository
    Start by initializing a new Git repository in your project directory:

    git init
    
  2. Configure Remote Repository
    Link your local repo to a remote one (e.g., GitHub, GitLab):

    git remote add origin <remote_url>
    
  3. Push Code to Remote
    Commit and push your code to the remote repository:

    git add .
    git commit -m "Initial deployment"
    git push -u origin main
    
  4. Automate Deployment
    Use tools like GitHub Actions or GitLab CI/CD to automate deployment workflows.
    Learn more about GitHub Actions

🌐 Deployment Workflow

  • Local Development
    Make changes locally and commit them with descriptive messages.

  • Push to Remote
    Push your commits to the remote branch, triggering automated deployment pipelines.

  • Server Sync
    Your server pulls the latest code from the remote repo, ensuring consistency.

📦 Example: Deploying a Static Site

  1. Create a deploy script:

    #!/bin/bash
    git pull origin main
    npm run build
    rsync -av build/ user@server:/var/www/html
    
  2. Run the script periodically or via a cron job.

📌 Tips

git_deployment
github_actions