Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
67 views

Efficient Python Tricks and Tools For Data Scientists (Git and GitHub)

This document provides several tips and tools for working with Git and GitHub from the terminal, including: 1) The GitHub CLI allows you to create a new GitHub repository from an existing local folder in one command. 2) You can pull a single file from another Git branch into your current branch without merging other changes. 3) The wget command can be used to download individual files like CSVs from GitHub without cloning the entire repository. 4) The github1s tool lets you view GitHub code with Visual Studio Code syntax highlighting directly in your browser.

Uploaded by

Xander Rodriguez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Efficient Python Tricks and Tools For Data Scientists (Git and GitHub)

This document provides several tips and tools for working with Git and GitHub from the terminal, including: 1) The GitHub CLI allows you to create a new GitHub repository from an existing local folder in one command. 2) You can pull a single file from another Git branch into your current branch without merging other changes. 3) The wget command can be used to download individual files like CSVs from GitHub without cloning the entire repository. 4) The github1s tool lets you view GitHub code with Visual Studio Code syntax highlighting directly in your browser.

Uploaded by

Xander Rodriguez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Efficient Python Tricks and Tools for

Data Scientists - By Khuyen Tran

Git and GitHub


GitHub View on GitHub Book View Book

This section shows some tricks and tools to work with Git and
GitHub.
GitHub CLI: Brings GitHub to Your
Terminal
If you create a local folder before creating a GitHub repository for
it, you might need to go to the GitHub website then create a new
repository, then add a remote to your current folder. Is there any
way that all of these steps could be done in the terminal in 1 line of
code?

That is when GitHub CLI comes in handy. The code snippet below
shows how to create a new Github repository in your local folder.

$ cd your_local_folder

# Create an empty local git repo


$ git init

# Create a new GitHub repo


$ gh repo create

With GitHub CLI, you can also manage your pull requests, issues,
repositories, gists, and so much more! Check out GitHub CLI here.
Pull One File from Another Branch Using
Git
Pull the files from another branch into your branch can be messy.
What if you just want to pull one file from another branch? You can
easily to like that with the code snippet below:

# downloads contents from remote repository


$ git fetch

# navigate to another branch


$ git checkout

# adds a change in the working directory to


the staging area
$ git add

# captures the state of a project at that


point in time
$ git commit

Now you just update one file in your branch without messing with
the rest!
Download a File on GitHub Using wget
If you want to download a file on GitHub such as a csv file, instead
of cloning the repo, simply use the code snippet above. For
example, if the website the file you want to extract is https://github.
com/khuyentran1401/Data-science/blob/master/visualization/dropd
own/population.csv, type:

$ wget
https://raw.githubusercontent.com/khuyentran14
01/Data-
science/master/visualization/dropdown/populati
on.csv

Now the data is in your directory!


github1s: Read GitHub Code with VS
Code on your Browser in One Second
Syntax highlighting in VS Code makes it easy for you to
understand the source code. Is there a way that you can read
GitHub code with VS Code in 1 second?

Yes, there is. Simply replace ...

github.com/yourname/repository with
github1s.com/yourname/repository

... to view Github with VS Code. It should show up like below.


Here is an example.
Astral: Organize Your GitHub Stars with
Ease
I have been sharing many tools and you might not be able to keep
up with them. To save and organize the tools you discovered on
GitHub, you can use Astral.

With Astral, you can organize my starred GitHub repositories like


below.

I have been using this for months, and it is super quick when I want
to find the right tool for my project.

Link to Astral.
pip install -e: Install Forked GitHub
Repository Using Pip
Sometimes, you might fork and make some changes to the original
GitHub repository. If you want others to install your forked repo,
use

pip install -e
git+https://github.com/username/package.git#egg=pa
ckage.

The code below shows how to install the forked repo of NumPy.

$ pip install -e
git+https://github.com/khuyentran1401/numpy.gi
t#egg=numpy

You might also like