Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Getting Started with Git: A Minimal Practical Guide

Tech 1

To begin using Git for version control:

  1. Navigate to your project directory in the file explorer, right-click, and select Git Bash Here.

  2. Clone your remote repository:

git clone <repository-url>

This creates a local folder named after the repository, containing a .git subdirectory.

  1. Enter the cloned directory:
cd <repository-name>
  1. Check the current status of your working tree:
git status
  1. Stage all changes (e.g., new or modified files):
git add .
  1. Commit the staged changes with a descriptive message:
git commit -m "update"
  1. Synchronize with the remote repository:
git pull origin main

Then push your local commits:

git push origin main

Note: Use main instead of master if your default branch is named main.

  1. Verify the repository state again:
git status

Core Workflow Summary

  • Initialize: Always start by cloning the remote repo into your local environment.
  • Stage Changes: Use git add . to enclude all modifications in the next commit.
  • Commit Locally: Record chenges with git commit -m "message".
  • Sync Remotely: Fetch updates with git pull before pushing with git push to avoid conflicts.

Useful Commands

  • View commit history:

    git log
    
  • Amend the most recent commit message:

    git commit --amend
    
  • Commit all tracked files without explicit staging:

    git commit -am "message"
    
  • Create a new file (optional):

    touch README.md
    
  • Edit files via terminal (using Vim):

    vim filename
    # Press 'i' to edit, 'Esc' then ':wq' to save and exit
    

Ensure your local changes are always pulled before pushing to maintain synchronization with the remote repository.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.