Few days ago we talk about
1- Initiate git object in python by providing path:
2- If you want to
3- Let's say you want to set username and email for git author:
4- Now to add a specific file to staged:
5- Commit the staged file with a message:
6- The final step is to push to a remote repo:
#python #git #gitPython #pull #push #author
gitPython
to work with git inside of python. The code below is a sample that would do all routine tasks like pulling and pushing or commit.1- Initiate git object in python by providing path:
from git import Repo
repo = Repo(repo_path)
2- If you want to
pull
results from git repo:repo.git.pull('origin', 'refs/heads/dev')
3- Let's say you want to set username and email for git author:
config = repo.config_writer()
config.set_value("user", "email", author_email)
config.set_value("user", "name", author_name)
4- Now to add a specific file to staged:
index = repo.index
index.add([file_path])
5- Commit the staged file with a message:
index.commit(commit_message)
6- The final step is to push to a remote repo:
repo.git.push('origin', 'refs/heads/dev')
#python #git #gitPython #pull #push #author
https://stackoverflow.com/questions/4309156/commit-specific-lines-of-a-file-to-git?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
#git #commit
#git #commit
Stack Overflow
Commit specific lines of a file to git
Possible Duplicate:
How can I commit only part of a file in git
How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the same file.
How can I commit only part of a file in git
How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the same file.
I sometimes forgot to pull data from git before start working on a project. To minimize the headache of merge conflict or having to
If you have similar issues and you're solving it in a different manner, I'd be happy to hear about it. :)
#linux #mac #bash #script #git #cron #crontab #cronjob
reset head
and stash
your data you can set a cronjob to run every 10 minute or so. And inside of your bash script CD
into eaach of your folders and issue git pull
command.If you have similar issues and you're solving it in a different manner, I'd be happy to hear about it. :)
#linux #mac #bash #script #git #cron #crontab #cronjob
If you forget to pull your projects from git in a regular interval and many users working on the same projects, then there is a solution for you!
Create a bash script file as follow and make it executable by
Now as a final step, put it in your crontab:
#linux #git #pull #cronjob #crontab #cron #bash
Create a bash script file as follow and make it executable by
chmod +x puller.sh
:puller.sh
file content:#!/bin/bash
echo 'Iterating over folders...'
for dir in *
do
test -d "$dir" && {
cd ${dir}
echo "git pull $dir"
git pull
cd ".."
} || {
echo "------> $dir is not a directory <-------"
}
done
NOTE:
this file should reside in your folder's project root. In my case it is in /Your/Projects/Folder
.Now as a final step, put it in your crontab:
10 * * * * bash -c "cd /Your/Projects/Folder; bash puller.sh >> /var/log/git_pull_output.log"
#linux #git #pull #cronjob #crontab #cron #bash
How to delete a git branch?
https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote
#git #branch #delete
https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote
#git #branch #delete
https://stackoverflow.com/questions/18770545/why-is-my-git-submodule-head-detached-from-master
#stackoverflow #git #submodule
#stackoverflow #git #submodule
Stack Overflow
Why is my Git Submodule HEAD detached from master?
I am using Git submodules. After pulling changes from server, many times my submodule head gets detached from master branch.
Why does it happen?
I have to always do:
git branch
git checkout mas...
Why does it happen?
I have to always do:
git branch
git checkout mas...