Efficient Python Tricks and Tools For Data Scientists (Git and GitHub)
Efficient Python Tricks and Tools For Data Scientists (Git and GitHub)
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
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:
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
github.com/yourname/repository with
github1s.com/yourname/repository
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