git commands, clone = checkout git stash, git commit, git push, git pull, and Djnago common used commands in deployment
When you start committing projects, merge to apply trunk in all branches so that it continues with additional functionalities that should come in all versions. Test your code first to make sure there are no errors that you would unexpectedly apply in deployment. Start trunk in development, separately with development database and config.
When you start committing.
git status
This command shows you what has already been changed since the last commit.
git add
With "git add" comand you can add files in commit to push it to the server.
git add *
Some people do everything in commit but I don't recommend it because several unnecessary files can get into commit so it might work better with one behind the other files.
For example
git add crawler/management/commands/adzunaxml.py crawler/management/commands
Now you comit your changes with a comment so that with the next command you can push all changes.
git commit
git push
Successfully push in trunk?
Then you can go to the next step and marge trunk with development branche
To make clear that we always have trunk it is never installed anywhere you can run it separately but trunk is a central code base that is central in all branches.. Then each branch may have its own version differences which is usually needed for different countries and different languages because not only translation is important in some countries customers and customer requirements are completely different and there are differences that's why we make a separate branche for each country.
Trunk would be the main body of development, originating from the start of the project until the present. Branch will be a copy of code derived from a certain point in the trunk that is used for applying major changes to the code while preserving the integrity of the code in the trunk.
So in this way if we change something that has yet to be applied in all versions. Then we do that in trunk / master, then we commit it to trunk / master.. Then we read it in development branch of a certain country, test, and make database changes, translations etc. in developlent.. When everything is ready and everything tested then we put it in development and update the deployment version. In this way we ensure that the wrong version of a site is never set up or mixed.
In development version of a certain branch
DEV
git remote -v show
git pull upstream master ( marge trunk with confilcts )
grep -r "<<<<<<< HEAD"
In most of conflicts head should be.. For ads
git commit
git push
DEP
In deployment can you then pull changes marged with trunk.
git pull ( branche in deployment )
git pull origin master
Yet another example that often could occur.
Git stash
git stash = local copy save and return to head.
# ... hack hack hack ...
$ git stash
$ edit emergency fix
$ git commit -a -m "Fix in a hurry"
$ git stash pop
# ... continue hacking ...
Only if you need to download something first.
Git restore
If you haven't already initiated the deletion process, you can simply execute `git restore <filename>`, and the file will be recovered from the index. However, if you have already staged the changes, running `git restore` will result in an error because the file no longer exists in the index.
deleted: vehicles/templates/cars_list.py
git restore vehicles/templates/cars_list.py
Checking Out with Git:
In the world of version control systems, Git is a powerful tool that allows developers to manage and track changes in their projects efficiently. One of the fundamental commands in Git is `checkout`. This command serves various purposes, making it an essential part of any developer's toolkit.
The primary function of `git checkout` is to switch between different branches in a Git repository. This is particularly useful when working on collaborative projects or managing different features or bug fixes simultaneously. You can effortlessly move from one branch to another using the command, ensuring that you are working on the correct codebase for your current task.
Here's a basic usage of `git checkout` to switch branches:
```shell
git checkout <branch_name>
```
Additionally, `git checkout` can be used to:
1. Create a New Branch: You can create a new branch and switch to it in a single command.
```shell
git checkout -b <new_branch_name>
```
2. Revert Changes: If you want to discard changes made to a specific file, you can use `git checkout` to restore the file to its last committed state.
```shell
git checkout <filename>
```
3. Checkout Specific Commit: You can also use `git checkout` to examine the state of your project at a particular commit.
```shell
git checkout <commit_hash>
```
Now, let's shift our focus to Django projects and the number of commands needed to compile translations and modify the database.
Django Project Translation and Database Commands:
Django, a popular Python web framework, provides commands that simplify the process of handling translations and database modifications.
1. Translations: In Django, handling translations is streamlined using the `makemessages` and `compilemessages` management commands.
- `makemessages`: This command scans your Django project for translation strings and generates .po files for each language.
```shell
python manage.py makemessages -l <language_code>
```
- `compilemessages`: Once you have translated strings in .po files, you can compile them into .mo files for efficient language support.
```shell
python manage.py compilemessages
```
These commands make it easy to create and maintain multilingual web applications.
2. Database Modifications: Django provides powerful database migration tools through the `makemigrations` and `migrate` commands.
- `makemigrations`: When you make changes to your Django models (e.g., adding new fields), this command generates migration files to track those changes.
```shell
python manage.py makemigrations
```
- `migrate`: The `migrate` command applies these migrations, updating your database schema accordingly.
```shell
python manage.py migrate
```
These commands ensure that your database structure remains synchronized with your Django project's models.
In summary, Git's `checkout` command is a versatile tool for managing branches and handling changes in your codebase. Meanwhile, Django simplifies translation management and database modifications with user-friendly commands like `makemessages` and `migrate`, making it an excellent choice for web development projects.
Number of commands with which one can compile translations and modify database.
python manage.py makemessages
python manage.py compilemessages
Full post about translation in Django
https://www.webdeveloper.today/2020/12/django-translation-commonly-used.html
python manage.py makemigrations viewjob
python manage.py migrate viewjob
More information about changes to the database, this operation is also common because we still work with relative database.
https://www.webdeveloper.today/2021/03/add-database-field-adjust-models-for.html
Comments
Post a Comment