Skip to content

Instantly share code, notes, and snippets.

View johngorithm's full-sized avatar
🏠
Working from home

Johngorithm johngorithm

🏠
Working from home
View GitHub Profile
@johngorithm
johngorithm / squash_commit.md
Last active October 16, 2019 08:40
The Best Approach to Squashing Commits

This can be done easily without git rebase or git merge --squash. In this example, let's squash the last 2 commits.

If you want to squash and write a new commit message, use the command below

git reset --soft HEAD~2

The 2 above points at the last 2 commit counting from the HEAD which is the top most commit in history
followed by

git commit


To squash and edit the combination of the existing commit messages, use the commands below

@johngorithm
johngorithm / shadow.xml
Created September 15, 2019 14:27 — forked from lecho/shadow.xml
Android shadow drawable xml.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"

To undo a commit and return the changes back to staging. Use the command blow

git reset --soft HEAD^

To remove staged file staging with Git, follow the link below

Stack Overflow

The link below show how one can change a repository's remote link from the command line.

This is essentially important when switching form either HTTPS TO SSH or vice-versa

Learn More

To view all files in your project that are ignored by Git without looking into .gitignore file, run the command below

git ls-files --others --ignored --exclude-standard
import android.content.Context;
import java.io.File;
public class CacheManager {
/**
* Private Constructor to make this a Utility class.
*/
private CacheManager() {
// Private constructor

Description

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.

Usage

Make sure you are on the branch you want to apply the commit to.

git checkout master

package com.jxw.graphql;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.IdlingRegistry;
import android.support.test.espresso.idling.CountingIdlingResource;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.rule.ActivityTestRule;
import com.jxw.graphql.test_utils.TestDemoApplication;
@Test
public void testTeachersAreDisplayed() throws IOException {
/**
* Setting up mockWebServer at localhost:9900.
*/
MockWebServer server = new MockWebServer();
// start the server at port 9900
server.start(9900);
/**