Skip to content

Version Code

DagsHub relies on Git for code versioning. It provides a hosted Git server with each project, or the ability to connect your existing repository from GitHub, GitLab, or Bitbucket, which lets you use your existing code, in a more machine learning-friendly interface.

For a beginners guide to Git check out this blog.

If you're more advanced, and want to learn more about Git, check out Think Like (a) Git.

Below is a simple example, that lets you create a new code version with DagsHub, it appears whenever you create a blank project with DagsHub.

# Clone a repository
git clone https://dagshub.com/<user_name>/<repo_name>.git
cd hello_world_git

# Create a simple file
echo "# hello_world_git" >> README.md

# Add file to Git tracking
git add README.md
git commit -m "first commit"

# Change local branch name to "main"
git branch -M main

# Push to DagsHub
git push -u origin main

After running these commands, your repo will look like this:

Project After Code Push

Next Steps

Now, let's learn how to version your datasets alongside your code!