Advance Git & GitHub

Advance Git & GitHub

Git stash:

Git stash is a command that allows you to temporarily save changes you have made in your working directory, without committing them. This is useful when you need to switch to a different branch to work on something else, but you don't want to commit the changes you've made in your current branch yet.

To use Git stash, you first create a new branch and make some changes to it. Then you can use the command git stash to save those changes. This will remove the changes from your working directory and record them in a new stash. You can apply these changes later using git stash pop. git stash list command shows the list of stashed changes.

You can also use git stash drop to delete a stash and git stash clear to delete all the stashes.


Cherry-pick:

git cherry-pick allows you to apply a specific commit from one branch to another. This can be useful when you want to selectively bring changes from one branch to another without merging the entire branch.


# Switch to the destination branch

git checkout master

# Cherry-pick a specific commit from another branch

git cherry-pick <commit-hash>


Resolving Conflict:

Resolving conflicts in Git occurs when there are conflicting changes between branches or commits that Git cannot automatically merge. When you attempt to merge or cherry-pick changes and conflicts arise, Git will mark the conflicted files.

While doing git merge dev i have sees there was a merge conflict.

Here's how to solve it:

use git status to see which files are conflicted.

Here We know conflict is in index.html file, so just open the file in any text editor.

I am using vim editor.

Here we can see that from <<<<<<<HEAD till ======== is the latest commit on another branch and from ===== till >>>>>>dev is the latest commit from dev branch, now while merging both branch i am getting conflict so i have manually resolve the conflict.

After Resolving mark the file as resolved:

git add index.html

git commit -m "Conflict Resolved" or use git rebase --continue.


Thats it for today, Keep Learning Keep Growing.





ramakrishna reddy

wotking as Production support specialist with 8 plus years experience.

1 年

intrested

要查看或添加评论,请登录

Ajay Kadam的更多文章

  • DevSecOps Jenkins CI/CD Pipeline for a Node.js Application

    DevSecOps Jenkins CI/CD Pipeline for a Node.js Application

    Requirements: JDK and Jenkins Docker and docker-compose SonarQube Trivy OWASP Dependency Checker GitHub Machine with…

    4 条评论
  • Day 29: Jenkins Interview Questions

    Day 29: Jenkins Interview Questions

    In today's fast-paced software development landscape, mastering Continuous Integration and Continuous Deployment…

    1 条评论
  • Day 28: Jenkins Agents

    Day 28: Jenkins Agents

    Jenkins Master (Server) Jenkins’s server or master node holds all key configurations. Jenkins master server is like a…

  • Day 27: Jenkins Declarative Pipeline

    Day 27: Jenkins Declarative Pipeline

    Some terms for your Knowledge What is Pipeline - A pipeline is a collection of steps or jobs interlinked in a sequence.…

  • Day 26: Simple Jenkins Pipeline

    Day 26: Simple Jenkins Pipeline

    We will Create a Jenkins Pipeline to simply print "Hello World". What is Pipeline - A pipeline is a collection of steps…

  • Copy of Day 24: Complete Jenkins CI/CD Project

    Copy of Day 24: Complete Jenkins CI/CD Project

    What are GitHub Webhooks? GitHub Webhooks are user-defined HTTP callbacks triggered by events occurring within a…

  • Day 23: Jenkins Freestyle Project for DevOps Engineers.

    Day 23: Jenkins Freestyle Project for DevOps Engineers.

    What Is a Build Job? A Jenkins build job contains the configuration for automating a specific task or step in the…

    2 条评论
  • Day 22: Getting Started with Jenkins ??

    Day 22: Getting Started with Jenkins ??

    Understanding Jenkins At its core, Jenkins is a (CI/CD) tool, meaning it helps automate the process of building…

  • Day 21:Demystifying Docker: A Comprehensive Guide to Common Interview Questions

    Day 21:Demystifying Docker: A Comprehensive Guide to Common Interview Questions

    In recent years, Docker has revolutionized the way we build, ship, and run applications. Its popularity has soared…

  • Day 19: Docker Network and Docker Volumes

    Day 19: Docker Network and Docker Volumes

    DOCKER Network: ?? Exploring the Power of Docker Networking! ?? Docker has revolutionized the way we deploy and manage…

社区洞察

其他会员也浏览了