Advance Git & GitHub
Ajay Kadam
Learning Devops | Python | AWS | Linux | Git | GitHub | Docker | Jenkins | kubernetes
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.
wotking as Production support specialist with 8 plus years experience.
1 年intrested