"Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency." Source
Minimal set up:
git config --global user.name "Your Name"
git config --global user.email youremail@example.com
Optional git aliases:
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git init # For initialising a new project
git add .
git commit -am "Note about what you changed"
git remote add origin git@bitbucket.org:REPO/proj_name.get
git push -u origin main
git rm file1.txt
git commit -m "remove file1.txt"
If changes are made but not committed, they can be discarded.
# Revert changes to modified files.
git reset --hard
# Revert changes to a specific point in time.
git reset --hard master@{"10 minutes ago"}
# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd
git branch dev
git checkout dev
# OR for the first time you can combine the commands
git checkout -b dev
# EDIT PROJECT CODE
git status
git add .
git commit -m "A note about the code changes made."
git checkout main
git merge dev
git push -u origin main
git push origin :newfeaturebranch # Delete remote branch
git branch -d newfeaturebranch # Delete local branch
Note: For Django, remove the secret key from settings.py and put it into local_settings.py. Just in case you make your project public in the future you need to minimise security risks.
Add files to be ignored and not stored in version control by typing nano .gitignore
in the project root::
*.pyc
*.pyo
db.sqlite3
*.db
.DS_Store
local_settings.py
/static
/proj_name/static/media/
*~
*.kate-swp