Skip to content

Latest commit

 

History

History
77 lines (66 loc) · 1.62 KB

Basic-Git-Commands.md

File metadata and controls

77 lines (66 loc) · 1.62 KB

Basic Git Commands

Checking Status

  • View the status of your working directory and staging area:
    git status

Adding Files

  • Stage changes (add files to the staging area):
    git add filename
    git add .

Committing Changes

  • Commit changes with a message:
    git commit -m "Your commit message"

Viewing Commit History

  • View the commit history:
    git log

Pushing Changes

  • Push changes to the remote repository:
    git push origin branch-name

Pulling Changes

  • Pull changes from the remote repository:
    git pull origin branch-name

Creating and Switching Branches

  • Create a new branch:
    git branch new-branch-name
  • Switch to a branch:
    git checkout branch-name

Merging Branches

  • Merge a branch into the current branch:
    git merge branch-name

Handling Merge Conflicts

  • Git will alert you if there are conflicts.
  • Open the conflicting files and resolve the conflicts.
  • After resolving, add the resolved files:
    git add filename
  • Commit the merge:
    git commit -m "Resolved merge conflict"

Summary

  • Git: A powerful tool for version control.
  • GitHub: A platform for hosting Git repositories and collaborating.
  • Basic Workflow:
    1. Initialize a repository.
    2. Connect to GitHub.
    3. Add, commit, push, and pull changes.
    4. Use branching and merging for collaborative work.

By mastering these basics, beginners can effectively start managing their projects and collaborating with others using Git and GitHub.