Git Cherry-Picking

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

What is Git Cherry-Picking?

Git is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.

Cherry picking in git means to choose a commit from one branch and apply it onto another.
This is in contrast with other ways such as merge and rebase which normally apply many commits onto another branch. In other words, cherry-picking is when you want to take the contents of a single commit from another branch and copy-paste them to a destination branch as a brand new commit.

Quick Summary of Git Cherry-picking steps

  • Find the commit hash you want to cherry-pick.
  • Go to your destination branch.
  • git cherry-pick -x commit-hash
  • Resolve conflicts if they occur.
  • If there are notes in the original commit, copy them over.

Detailed Git Cherry-picking process

  1. From the origin branch where you want to cherry pick from, run this command to get the commit has needed:
    <code
    git reflog.

    </code

  2. Make sure you are on the branch you want to apply the commit to.
    git checkout
    Execute the following for the typical cherry-pick command is simply:
    git cherry-pick commit-hash
    As developers, we often perform a series of steps to achieve our objectives. Showing you an isolated cherry-pick command is the same as throwing you the manual and asking you to read it.
  3. If you cherry-pick from a public branch, you should consider using
    git cherry-pick -x commit-hash
    This will generate a standardized commit message. This way, you (and your co-workers) can still keep track of the origin of the commit and may avoid merge conflicts in the future.
  4. If you have notes attached to the commit they do not follow the cherry-pick. To bring them over as well, You have to use:
    git notes copy from_commit_hash to_commit_hash

References:

Git Cheat Sheet

AI Dashboard is available on the Web, Apple, Google, and Microsoft, PRO version

Find Useful Git commands in this Git Cheat Sheet.

Here is a basic Git cheat sheet:

git init – Initialize a new git repository

git clone [repository] – Clone an existing repository

git status – Check the status of your repository


git add [file] – Add a file to the repository

git commit -m "[message]" – Commit changes with a message

git push – Push changes to a remote repository


AI Unraveled: Demystifying Frequently Asked Questions on Artificial Intelligence (OpenAI, ChatGPT, Google Bard, Generative AI, Discriminative AI, xAI, LLMs, GPUs, Machine Learning, NLP, Promp Engineering)

git pull – Pull changes from a remote repository

git branch – Show the current branch

git branch [branch-name] – Create a new branch

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLF-C02 book

git checkout [branch-name] – Switch to a different branch

git merge [branch-name] – Merge a branch into the current branch

git log – Show the commit history

git diff – Show changes between commits

git reset --hard [commit] – Reset repository to a specific commit

git stash – Stash changes

git stash apply – Apply stashed changes

Please note that this is a basic cheat sheet and git has many more functionalities and options, it is worth reading the git documentation to learn more.

  • Clone a project:
    git clone git_repo_url project_name
  • Switch to a branch locally:
    git checkout branch_name
  • Modify a file, then save and push it to remote repo in current branch
    git add path_to_file_modifeid/file_name
    git commit -m “Description of modification”
    git push
  • Get a new version of a file after modifying local version
    git checkout path_to_file_modified/file_modified
  • Get latest version of current branch
    git fetch
    git pull
    if you have local changes, you will be prompted to commit or stash them before pulling.
  • Create a new branch based on current branch and switch to it
    git checkout –b branch_name
  • Switch to master branch
    git checkout master
  • Merge branch_name to master
    git merge branch_name
  • Delete local branch
    git branch -d branch_name
  • Undo a merge or pull
    git reset –hard
  • Undo a commit locally and on the remote branch
    git reset –hard commit_id
    git push –force
  • Get remote url of a local branch
    git remote show origin

Source: https://git-scm.com

Pass the 2023 AWS Cloud Practitioner CCP CLF-C02 Certification with flying colors Ace the 2023 AWS Solutions Architect Associate SAA-C03 Exam with Confidence Pass the 2023 AWS Certified Machine Learning Specialty MLS-C01 Exam with Flying Colors

List of Freely available programming books - What is the single most influential book every Programmers should read



#BlackOwned #BlackEntrepreneurs #BlackBuniness #AWSCertified #AWSCloudPractitioner #AWSCertification #AWSCLFC02 #CloudComputing #AWSStudyGuide #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AWSBasics #AWSCertified #AWSMachineLearning #AWSCertification #AWSSpecialty #MachineLearning #AWSStudyGuide #CloudComputing #DataScience #AWSCertified #AWSSolutionsArchitect #AWSArchitectAssociate #AWSCertification #AWSStudyGuide #CloudComputing #AWSArchitecture #AWSTraining #AWSCareer #AWSExamPrep #AWSCommunity #AWSEducation #AzureFundamentals #AZ900 #MicrosoftAzure #ITCertification #CertificationPrep #StudyMaterials #TechLearning #MicrosoftCertified #AzureCertification #TechBooks

Top 1000 Canada Quiz and trivia: CANADA CITIZENSHIP TEST- HISTORY - GEOGRAPHY - GOVERNMENT- CULTURE - PEOPLE - LANGUAGES - TRAVEL - WILDLIFE - HOCKEY - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
zCanadian Quiz and Trivia, Canadian History, Citizenship Test, Geography, Wildlife, Secenries, Banff, Tourism

Top 1000 Africa Quiz and trivia: HISTORY - GEOGRAPHY - WILDLIFE - CULTURE - PEOPLE - LANGUAGES - TRAVEL - TOURISM - SCENERIES - ARTS - DATA VISUALIZATION
Africa Quiz, Africa Trivia, Quiz, African History, Geography, Wildlife, Culture

Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada.
Exploring the Pros and Cons of Visiting All Provinces and Territories in Canada

Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA
Exploring the Advantages and Disadvantages of Visiting All 50 States in the USA


Health Health, a science-based community to discuss health news and the coronavirus (COVID-19) pandemic

Today I Learned (TIL) You learn something new every day; what did you learn today? Submit interesting and specific facts about something that you just found out here.

Reddit Science This community is a place to share and discuss new scientific research. Read about the latest advances in astronomy, biology, medicine, physics, social science, and more. Find and submit new publications and popular science coverage of current research.

Reddit Sports Sports News and Highlights from the NFL, NBA, NHL, MLB, MLS, and leagues around the world.

error: Content is protected !!