How can i Pull a single file change from github? - python

Hello Stackoverflow and hello to all the developers .
Sir actually i am running in a problem .
I've hosted my new blog website on a linux vps , and when i hosted that it was just a bare minimum ,
now it's running perfectly on that vps and on my computer i am trying to add more features to it . but there is a problem when i push all changes to github and pull that changes to that vps it will changing my settings file , which is extremely important . now i am looking for a solution that i can pull single file changes not entire .
for example
i made image responsive in style.css file okay and push that change to github
how can i download that single change, single file change or that single file (style.css) to that vps?
if you will help me i will be very gladful to you

git fetch --all
git checkout origin/master -- <your_file_path>
git add <your_file_path>
git commit -m "<your_file_name> updated"
First checkout to branch from where you want to pull.

This is similar to this question: Git: How to pull a single file from a server repository in Git?
So..
git fetch
then
git checkout (-p|--patch) [] [--] […​]
see https://git-scm.com/docs/git-checkout

Related

I'm working on a gitlab cicd pipeline. I want the pipeline to run a python script, which creates files in the gitlab repository

The files I create seem to be deleted after the script is completed. If I print the existing files in the python script they show, but aren't to be found in the repository. Is there any option I have to set for the files to stay?
This is the part of the gitlab-ci.yml responsible for running the python script:
retrieve-tags:
stage: build
script:
- pip3 install python-gitlab
- pip3 install markdown
- python3 retrieve_tags.py
image: python
artifacts:
paths:
- .*
This is the part of the python script that should create files, but doesn't really:
path = CENSORED FOR REASONS
file_name = "test.txt"
with open(os.path.join(path,file_name), 'w') as fp:
fp.write("TAG_CONTENTS")
fp.close()
print(os.listdir(path))
I expect this to create files in the gitlab repository, in which the cicd pipeline is running and to view created files in the repository after the script ran.
Gitlab pipeline jobs are run on ephemeral virtual machines. Any changes you make to your repository are lost unless you push or upload those changes somewhere.
You can use normal Git commands to add and push your changes. For example:
git add .
git commit -m "My changes"
git push -o ci.skip "https://${GITLAB_USER_NAME}:${GITLAB_TOKEN}#${CI_REPOSITORY_URL#*#}"
GITLAB_TOKEN can be one of the token types on this page which has write_repository permissions.
Inspiration found on this answer.
Your project is cloned to the runner. So the changes you make are only visible inside the runner. To Push back the changes to the repository, you have to commit and push them, just like on your local machine.
- git config user.name "YourName"
- git config user.email "YourName#email.com"
- git add . # be careful with this and ensure your .gitignore is correct.
- git commit -m "Update from pipeline"
- git push
This workflow has the risk of merge conflicts when your Pipeline runs for a long time.
An alternative to adding these files to the repository is to create Job Artifacts as you already did. But they are not added to the repo, but can be viewed on the right side of a Job Execution. And I wouldn't add all your files, as this can quickly fill up your disk space. You should just add the generated files.

How do I host my discord.py bot on heroku?

I am currently trying to get my discord bot on to Heroku and host it 24/7 but I am having problems.
I uploaded my bot to github https://github.com/zemocode/flankebot/tree/master
I have created the two main files I needed
I clicked deploy branch on Heroku and I'm getting this error.
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed
I have followed tutorials but everyone else has node.js and I so mine doesn't work.
You're missing a couple of things to make this work, for the sake of everyone Googling how to host discord.py on Heroku and getting this as the top result here's a step-by-step
Install Git and do git init when inside your directory
(If you're using virtualenv or similar go into it and) do pip freeze then copy the contents you get to a file called requirements.txt and save it in the same repository as the bot
Make a file (a file of type file)
, open it with notepad and write worker: python name_of_bot_file.py and save within the same repository
Make a text file called runtime.txt and paste python-3.6.5 or whichever python version you were using to write the bot and save it in the same repository.
(If you're inside virtualenv get out and) open your console and write heroku login and input your heroku login details
Then do heroku apps:create name_of_app and heroku buildpacks:set heroku/python
Finally, do git push heroku main or git push heroku branch_name:main if you want to only push one branch
your procfile isn't right. a web application(web:<command>) is for websites (which your bot isn't). the right one is worker: python3 bot.py.
Also, you need a requirements.txt. inside the file, write every module you need to download. in your case, its just discord.py.

git pull doesn't update files on pythonanywhere

I am following Django Girls Tutorial, I am on html section - https://tutorial.djangogirls.org/en/html/ - where git is updated than files are transferred to pythonanywhere by using git pull. My git has been updated however, after git pull on pythonanywhere I do not see updated Files. I rerun my web app as well, no changes.
After git pull I see files changes, insertions and deletion, but no files updated in FILES section.
Thank You for help,
Bogdan
enter image description here
I found this if your willing to give it a shot. It allows you to reload and push all to your pythonanywhere site. https://blog.pythonanywhere.com/87/

How do I merge a remote repo with my current existing directory?

I have my Django project in a Bitbucket repo that I want to merge with my newly created Digital Ocean server. The server directory contains a few basic files for a Django project for my server like env, static and manage.py. The Bitbucket repo has all my project apps etc. I've already done git remote add origin https://user#bitbucket.org/user/project.git from the server directory. So I then perform git merge master but it says Already up-to-date.. I've tried git pull master but it says:
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Any idea what I can try?
The git pull command is used like
git pull [options] [<repository> [<refspec>...]]
That means, that you if you are not using any [options] you use
git pull <repository>
which in your case would end up being
git pull origin
If you want to specify the branch then you can do it like this (for master)
git pull origin master
The command you used (git pull master) will not work, because you are telling git to pull from the repository master, which does not exist in your remotes. You can already tell my the error message 'master' does not appear to be a git repository.
If you want to get the changes and merge yourself you can use the git fetch command, which is being used my pull anyways.

Openshift: How to and the Drawbacks of a Hot Deployment

I work with Openshift and in specific with Python. I have done many projects in there and I think the most irretating thing is that when you deploy your application, the server is down and you cannot even show a custom message.
I was socked after months when I searched in Google that there is an option to Hot Deploy an application. To git push it without the server get down. I am not a computer scientist, so I cannot understand if this technique has any drawbacks on my application.
Also, until now, when I wanted to update my application, I was doing:
git add .
git commit -a -m 'mycommit'
git push
I read on the manual that I have to enable the Hot Deployment with creating a file on the directory:
C:\app_directory> copy NUL > .openshift\markers\hot_deploy
But after that, how will I (hot) deploy the changes in my server?
Thank you
Once you have added the hot_deploy marker to your git repository, you need to follow the same git add, git commit, git push procedure, the only difference will be that your site will not shut down while it is being deployed. The new code will be deployed and everything should work as expected.
You need to add the marker file to your Git to make the change through to the the server.
git add .openshift/markers/hot_deploy
git commit -m "Changing application to hot deploy"
After this your subsequent commits (using the git add/commit/push combination) will not restart your server.
Alternatively you can use the following rhc commands to enable and disable auto-deployment.
rhc app-configure <app> auto-deploy
rhc app-configure <app> no-auto-deploy

Categories