Did you push a very large file into git? Does everyone yell at you about your commit and your uselessness? Are you a junky punky like me that just ruin things? Oh I'm kidding...
Because of that big file cloning the repo again would take a long long time. Removing the file locally and pushing again would not solve the problem as that big file is in Git's history.
If you want to remove the large file from your git history, so that when everyone clone the repo should not wait for that large file, just do as follow:
I should note that you should be in the root of git repo.
If you need to do this, be sure to keep a copy of your repo around in case something goes wrong.
#git #clone #rm #remove #large_file #blob #rebase #filter_branch
Because of that big file cloning the repo again would take a long long time. Removing the file locally and pushing again would not solve the problem as that big file is in Git's history.
If you want to remove the large file from your git history, so that when everyone clone the repo should not wait for that large file, just do as follow:
git filter-branch --tree-filter 'rm path/to/your/bigfile' HEAD
git push origin master --force
I should note that you should be in the root of git repo.
If you need to do this, be sure to keep a copy of your repo around in case something goes wrong.
#git #clone #rm #remove #large_file #blob #rebase #filter_branch
I usually use linux copy command
files added into the project.
To revert all the C**P and make a clean slate of your project again, you just need to do 2 things:
1- git checkout .
2- git clean -f
First command will revert all modified files into their previous state. Second one will remove all untracked files.
Happy copying :)
#git #revert #checkout #clean #git_clean
cp
to copy files from my project into a production environment project. I copied wrong files by accident from a different repo into production environment and messed up the repo. Some files got into modified state, many untrackedfiles added into the project.
To revert all the C**P and make a clean slate of your project again, you just need to do 2 things:
1- git checkout .
2- git clean -f
First command will revert all modified files into their previous state. Second one will remove all untracked files.
Happy copying :)
#git #revert #checkout #clean #git_clean
Tech C**P
I usually use linux copy command cp to copy files from my project into a production environment project. I copied wrong files by accident from a different repo into production environment and messed up the repo. Some files got into modified state, many untracked…
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...