5 Git Concepts To Move Beyond The Beginner Developer
git cherry-pick, git stash, git hooks and more!
1. git cherry-pick
This is similar to picking the best cherries (i.e. commits) from a tree branch (i.e. a branch of your repository).
Check out the example below where we create a repository and add file1
to the master
branch.
> git init
> echo "lines in file1" >> file1
> git add .
> git commit -m "added file1 to master"
# Ashish creates a new branch : ashish_changes
> git checkout -b ashish_changes
# Ashish adds more lines to file1
> echo "lines to file1" >> file1
# Ashish commits the changes to 'ashish_changes' branch
> git commit -am "ashish's changes to file1"
> git checkout master
# John creates a new branch : john_changes
> git checkout -b john_changes
# John adds a new file
> echo "lines in file2" > file2
# John commits the changes to 'john_changes' branch
> git add file2
> git commit -m "file2 added"
# Repository's history
> git log --oneline --all --decorate --graph
* c83a4c6 (HEAD -> john_changes) added file2
| * dffe39c (ashish_changes) ashish'…
Keep reading with a 7-day free trial
Subscribe to Into AI to keep reading this post and get 7 days of free access to the full post archives.