Friday, August 4, 2017

GitHub: How to cherry-pick within a pull-request?

Source & Credits: https://gist.github.com/ozh/cbce675ba35e0d336cff

1. Create new branch:

git checkout -b otherrepo-master master

2. Get the contents of the PR

git pull https://github.com/otherrepo/my-repo-name.git master

3. Change back to master

git checkout master

4. Now DO NOT merge the whole branch, BUT cherry-pick exactly the commits from the other branch.

The hash uniquely defines the commit - regardless of the branch it is in.
git cherry-pick abc0123

5. Check, remove the temp branch, push

git log
git branch -D otherrepo-master
git push origin master

Tuesday, August 1, 2017

GIT: useful commands

Checkout and start tracking remote branch:
git checkout --track origin/branchname
Publish and create tracking connection for new local branch:
git push -u <remote> <branch>
Revert changes made to your working copy:
git checkout .
Revert changes made to the index: (i.e., that you have added). Warning this will reset all of your unpushed commits to master!
git reset
Revert a change that you have committed:
git revert <commit 1> <commit 2>
Remove untracked files (e.g., new files, generated files):
git clean -f
Remove untracked directories (e.g., new or automatically generated directories):
git clean -fd
Remove ignored files (e.g., IDE configuration):
git clean -fX
Remove ignored directories (e.g., IDE configuration, target dir)
git clean -fdX
Rebase develop branch to master. (Develop will be checked out):
git rebase master develop
Delete branch with all its commits:
git branch -D <branch-name>
Create patch file of staged changes (ignore whitespace differences, like line endings):
git diff --cached --ignore-space-change >> patch.diff
Clean up list of remote branches
git remote prune <origin>

sources:

Vagrant: frequently used commands

In everyday life you'll probably use the following two commands the most: vagrant halt to shutdown your machine, and vagrant up --provision to turn it on again.

vagrant up
This command creates and configures guest machines according to your Vagrantfile.
vagrant halt
This command shuts down the running machine Vagrant is managing.
vagrant destroy
This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.
vagrant up --provision
Same as vagrant up, but with forcing the provisioners to run.

source: Vagrant CLI documentation