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 / GitHub-Forking.md
Created February 9, 2019 16:21 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

package com.jxw.graphql.app;
//in: app/src/main/java/packageDir/app/
import android.app.Application;
public class DemoApplication extends Application {
public String getBaseUrl() {
return "https://api.graph.cool/simple/v1/cjs1qws8c0mvr0102fkeosj4p";
}
}
package com.jxw.graphql.service;
//in: app/src/main/java/packageDir/service/
import com.apollographql.apollo.ApolloClient;
import com.jxw.graphql.app.DemoApplication;
import com.jxw.graphql.type.CustomType;
import com.jxw.graphql.utils.CustomDateAdapter;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
package com.jxw.graphql.view;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.apollographql.apollo.ApolloCall;
import com.apollographql.apollo.api.Response;
import com.apollographql.apollo.exception.ApolloException;
package com.jxw.graphql.test_utils;
import com.jxw.graphql.app.DemoApplication;
public class TestDemoApplication extends DemoApplication {
private String baseUrl;
@Override
public String getBaseUrl() {
return baseUrl;
package com.jxw.graphql.test_utils;
import android.app.Application;
import android.content.Context;
import android.support.test.runner.AndroidJUnitRunner;
public class CustomTestRunner extends AndroidJUnitRunner {
@Override
public Application newApplication(ClassLoader cl, String className, Context context) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
return super.newApplication(cl, TestDemoApplication.class.getName(), context);
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);
/**

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