On boarding your 1st Crack Data Science project through Github Contribution

Eva Xue
Crack Data Science Community
5 min readFeb 13, 2022

In crack data science community, team collaboration is always the heart of our culture. We hope to provide an easy way for everyone to leverage the resources and contribute to the project.

Here is a step by step Github walkthrough tutoring for you to get a quick start.

Step 1. Request the collaboration access to Crack Data Science Project Repository

You will get email invitation once John Chan has added you into the team.

Step 2. Clone the project on local

Go to the working directory in terminal

git clone https://github.com/johnfcchan/crackdatescience.git

The entire project would be cloned to your local working folder

Step 3. Create your personal branch

Go to the folder you just cloned and create a branch with your name

cd crackdatescience
git branch [branch name]

Look for existing branches:

git branch -v
* represent which branch you’re working on

Switch to your personal branch:

git checkout [branch name]
Now you’re on your own branch
You can check again

Step 4. Working under your branch and commit your code

eg., you could add your files, codes in the working folder.

Example, I’ve added our group picture under crackdatascience folder.

Then I want to commit my code to my branch -exue

git status
git add *
git commit -m'take some note'
git push origin [branch name]

A new branch has been created in the repository

Click the tab to switch the branch

File has been committed under the personal branch.

Step 5 Retrieving the changes to local

git branch -v --all

git branch -v (without --all) only shows branches you've worked on. When you use --all you see all the tracking branches in origin/

git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn’t do any file transferring. This is useful to allow for checking before doing an actual pull, which could change files in your current branch and working copy (and potentially lose your changes, etc).)

it’s important to note that when you do a fetch that brings down new remote branches, you don’t automatically have local, editable copies of them. In other words, in this case, you don’t have a new branch serverfix– you only have a pointer origin/serverfixthat you can’t modify.

To merge this work into your current working branch, you can run git merge origin/serverfix.

git pull on the other hand does that AND brings (copy) those changes from the remote repository. git pull is a combination of git fetch and git merge.

Topic — Access Gitlab/Github through SSH key

Step 1. get ssh key from terminal

cd .ssh/
vi id_rsa.pub

Step 2. Copy - paste, adding public key in Gitlab

Step 3. Config gitlab

vi config
## add the access

Host gitlab.hq.<domain name>.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

Topic — Local & Remote Branch Conflicts

If we want to overwrite the remote branch, we could force push by funning the following code

git push -f

git push --force-with-lease

If we want to undo the git add commitment, we could restore the stage

git restore [file name]

The “restore” command helps to unstage or even discard uncommitted local changes.

Topic — Merge with master branch

git checkout master

#Switched to branch 'master'
#Your branch is up to date with 'origin/master'.

git pull origin master

git checkout [branch name]

git rebase -i master

#Conflict might raise in this step.
#Open the file in code editor (eg. Atom), resolve the conflict manually by selecting the final version

git status
git add [file name]
git commit -m"resolve merge conflict"

We will enrich this story when more Github collaboration is involved.

Thanks John Chan and Jo O for helping with these material.

Reference —

https://stackoverflow.com/questions/10510462/force-git-push-to-overwrite-remote-files

https://www.freecodecamp.org/news/git-fetch-vs-pull/

https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository

Crack Data Science Community

Mission- We hope to build a community which is inclusive, supportive, vulnerable, loving and caring. Empower each other to achieve continued success in data science career journey

If you haven’t done yet, here is the link where you could find us —

2021 Achievement

--

--

Eva Xue
Crack Data Science Community

Data Scientist | Growth Hacker | Lifetime Learner | Loving Helper