Update Git branches from master
2022-07-03
Question I have four branches (master, b1, b2, and b3). After I worked on b1-b3, I realized I have something to change on branch master that should be in all other branches. I changed what I needed in master and... here is my problem: How do I update all other branches with master branch code? Answer You have two options: The first is a merge, but this creates an extra commit for the merge.…
Push commits to another branch
2022-07-02
Question Is it possible to commit and push changes from one branch to another. Assume I commited changes in BRANCH1 and want to push them to BRANCH2. From BRANCH1, is it valid to do: git push origin **BRANCH2** And then reset BRANCH1? Answer That will almost work. When pushing to a non-default branch, you need to specify the source ref and the target ref: git push origin branch1:branch2 Or git push <remote> <branch with new changes>:<branch you are pushing to>
How do I remove files saying "old mode 100755 new mode 100644" from unstaged changes in Git?
2022-07-01
Question For some reason, when I initially did a pull from the repository for a git project of mine, I got a ton of files in my working copy that have no discernible changes made to them, but keep showing up in my unstaged changes area. I'm using Git Gui on Windows xp, and when I go to look at the file to see what has changed. All I see is:…
What are the differences between .gitignore and .gitkeep?
2022-07-01
Question What are the differences between .gitignore and .gitkeep? Are they the same thing with a different name, or do they both serve a different function? I don't seem to be able to find much documentation on .gitkeep. Answer .gitkeep isn’t documented, because it’s not a feature of Git. Git cannot add a completely empty directory. People who want to track empty directories in Git have created the convention of putting files called .…
Filter pandas DataFrame by substring criteria
2022-06-30
Question I have a pandas DataFrame with a column of string values. I need to select rows based on partial string matches. Something like this idiom: re.search(pattern, cell_in_question) returning a boolean. I am familiar with the syntax of df[df['A'] == "hello world"] but can't seem to find a way to do the same with a partial string match, say 'hello'. Answer Vectorized string methods (i.e. Series.str) let you do the following:…
Git - Ignore node_modules folder everywhere
2022-06-30
Question I have a project containing multiple other projects : Main project Mini project 1 Mini project 2 All containing node_modules folder. I want git to ignore the folder no matter where it is starting from the root folder. Something like this to add in .gitignore : *node_modules/* Answer Add node_modules/ or node_modules to the .gitignore file to ignore all directories called node_modules in the current folder and any subfolders like the below image.…
git pull fails "unable to resolve reference" "unable to update local ref"
2022-06-30
Question Using git 1.6.4.2, when I tried a git pull I get this error: error: unable to resolve reference refs/remotes/origin/LT558-optimize-sql: No such file or directory From git+ssh://remoteserver/~/misk5 ! [new branch] LT558-optimize-sql -> origin/LT558-optimize-sql (unable to update local ref) error: unable to resolve reference refs/remotes/origin/split-css: No such file or directory ! [new branch] split-css -> origin/split-css (unable to update local ref) I've tried git remote prune origin, but it didn't help.…