Back
Featured image of post Version Control Using Git and Github

Version Control Using Git and Github

his project should be put under version control. Git is the de facto tool for version control these days, so we’ll be using it to keep track of this project. While GitHub has become the main tool for hosting git repositories, I prefer using github or gitlab or bibucket, there is a git hosting for project or work.

Install git

git is cross platform tools to manage and save project or git hosting

Install on Windows

to install in windows go to docs to download

Install on Mac

to install in mac, install using brew

brew install git

Install git on Linux

if using ubuntu or debian use this command

sudo apt install git

if use arch linux using pacman

sudo pacman -S git

for RHELL

sudo dnf install git-all

Creating Repository

make sure have github account to continue on this chapter

open your github account and create repository

new git project
new git project

copy the following step

Initialize Project

initialize project with main branch

git init --initial-branch=main

Adding Python Gitignore

adding gitignore from github from this url: https://github.com/github/gitignore/blob/main/Python.gitignore and add to .gitignore file

drwxr-xr-x  6 feri  staff   192 Jan  3 12:07 .
drwxr-xr-x  5 feri  staff   160 Jan  3 00:20 ..
drwxr-xr-x  9 feri  staff   288 Jan  3 12:05 .git
-rw-r--r--  1 feri  staff  2761 Jan  3 12:08 .gitignore
drwxr-xr-x  5 feri  staff   160 Jan  3 02:06 backend
drwxr-xr-x  6 feri  staff   192 Jan  3 00:20 venv

Adding Remote Version

for example on my case, this remote avaialable to copy on blank repo on git

git remote add origin git@github.com:perymerdeka/D-Store.git

adding remote example
adding remote example

Push to Github

to push in github add file to github

git add .

And commit

git commit --message="Initial Project"

Push to github

git push origin main

Push to Github
Push to Github

Conclusion

how to set up a git repository to track the files in your Django project and how to create a remote repository on Github. This is a great foundation for using git going forward in the development of this Django application.

the project is available on Github

Licensed under CC BY-NC-SA 4.0
Last updated on Jan 11, 2022 23:42 +0700
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy