Tuesday, March 18, 2025

Common Git and Github integration Commands.

 

key commands:

Git is a widely used version control system. Here are some of the most common Git commands, categorized for better understanding:

1. Configuration and Setup
  • Set user name and email (required for commits)
    git config --global user.name "Devopspat35" git config --global user.email "patemf2021@yahoo.com"
  • git config --list
  • Initialize a new Git repository
    git init
2. Cloning and Remote Repositories
  • Clone a repository from GitHub/GitLab
    git clone https://github.com/Devopspat35/Pipeline-Webapplication
  • Add a remote repository
    git remote add <alias> https://github.com/Devopspat35/Pipeline-Webapplication
  • Show remote repositories
    git remote -v
3. Staging and Committing Changes (moving files from dev to staging)
  • Check the status of changes
    git status
  • Add files to staging area
    git add filename.txt # Add a specific file git add . # Add all modified files
  • Commit changes with a message
    git commit -m "Your commit message"
  • Commit all changes (skip staging step)
    git commit -am "Commit message"
4. Branching and Merging
  • List all branches
    git branch
  • Create a new branch
    git branch new-branch
  • Switch to another branch
    git checkout new-branch
  • Create and switch to a new branch
    git checkout -b new-branch
  • Merge a branch into the current branch
    git merge branch-name
  • Delete a branch
    git branch -d branch-name # Delete a local branch git push origin --delete branch-name # Delete a remote branch
5. Pushing and Pulling Changes
  • Push changes to a remote repository
    git push origin branch-name
  • Pull latest changes from a remote repository
    git pull origin branch-name
6. Viewing History
  • View commit history
    git log
  • View a one-line commit history
    git log --oneline
  • Show changes in commits
    git diff
7. Undoing Changes
  • Undo changes before staging
    git checkout -- filename.txt
  • Remove file from staging area
    git reset filename.txt
  • Undo the last commit but keep changes
    git reset --soft HEAD~1
  • Undo the last commit and discard changes
    git reset --hard HEAD~1
  • Revert a specific commit (creates a new commit to undo changes)
    git revert commit-id
8. Working with Tags
  • List all tags
    git tag
  • Create a new tag
    git tag v1.0
  • Push tags to remote repository

    git push origin --tags
9. Stashing Changes
  • Save uncommitted changes for later
    git stash
  • List stashes
    git stash list
  • Apply the last stash
    git stash apply
  • Apply and remove the last stash

    git stash pop
Addendum:
 
 

Double-click on the image to zoom-out ...Larger.

To return to Home page: Refresh Page or Take ESC Button on Keyboard

 
 

Double-click on the image to zoom-out ...Larger.

To return to Home page: Refresh Page or Take ESC Button on Keyboard


No comments:

Post a Comment

Kubernetes Clusters | Upstream Vs Downstream.

  The terms "upstream" and "downstream" in the context of Kubernetes clusters often refer to the direction of code fl...