Create Gitblit proposal ticket using git subtree - git-subtree

I have a project ProjectA that uses shared library LibB. LibB is added to ProjectA using git subtree:
git remote add rm_LibB ssh://user#127.0.0.1:222/LibB.git
git subtree add --prefix=libs/LibB --squash rm_LibB/master
According to this documentation to create a proposal ticket you should do:
git checkout -b mytopic
...add a single commit...
git push origin HEAD:refs/for/new
However in case of subtree I'm usually using:
git subtree push --prefix=libs/LibB rm_LibB master
if I want to push changes made in LibB(being in ProjectA) to a master branch on remote LibB reposioty.
So far I've tried to
git subtree push --prefix=libs/LibB rm_LibB refs/for/new
which results in creating a new branch refs/for/new on remote LibB repository with no ticket created.
My current solution is to create proposal ticket from web interface and then
git subtree push --prefix=libs/LibB rm_LibB ticket/N
where N is the ticket ID.
But I would like to be able to create proposal tickets automatically.

Related

Serve RMarkdown outputs without version controlling them

We frequently use RMarkdown based packages to create websites with R (bookdown, blogdown, distill...) and use github-pages to serve the html files via the url username.github.io/repo.
In this approach, the ouput (i.e. html / css) files are also version controlled, and are frequently included in commits by mistake (git commit -a). This is annoying since these files clutter the commit and often lead to fictitious files conflicts.
Ideally, the outputfiles would not be version controlled at all, since the binary files (images) additionally bloat the repo. So I'm looking for a solution where:
Git ignores the output files completely but provides an alternative (but comparable1) method to gh-pages to serve them
Git ignores the output files temporally and committing / pushing them to gh-pages is done in a separate, explicit command
1: The method should be command line based and provide a nice URL to access the website
You could have .html, .css etc. ignored in the main and all other branches but the branch, for example, the gh-page branch, where your github-page is built from.
Git does not support different .ignore files in different branches so you would have to set up a bash script that replaces the ignore file each time you checkout a new branch. See here for how to do that: https://gist.github.com/wizioo/c89847c7894ede628071
Maybe not the elegant solution you were hoping for but it should work.
If you have a python installation on your computer, you can use GitHub Pages Import, a tool designed specifically for this purpose.
You need a python installation since it has to be installed with pip, but once it's installed it integrates beautifully with into an R / RMarkdown workflow.
Once it's installed (pip install ghp-import), you can run ghp-import docs (assuming docs is where your RMarkdown outputs are stored).
There are a bunch of practical options that you can use, including -p to additionally push the changes to your remote after the commit.
You need to tell Git to ignore the folder the book gets built into.
So, for example, by default bookdown puts all the built files in a folder called "_book"
Just add the following line to the .gitignore file in your project.
_book
Then you can work on your book and build it and push changes without worrying about the site being updated.
To update the site, you want to create a gh-pages branch that is only used for the hosted content. Do that with these commands from in your book folder:
git checkout --orphan gh-pages
git rm -rf .
# create a hidden file .nojekyll
touch .nojekyll
git add .nojekyll
git commit -m"Initial commit"
git push origin gh-pages
Make sure (once you put your book content in that branch) that GitHub is set to use that branch for hosting, rather than the folder you were using before.
Then, you can switch back to your main branch with the following command:
git checkout master
Next, you will clone your gh-pages branch into your main project:
git clone -b gh-pages https://github.com/yourprojecturl.git book-output
Then, when you have a version of the built book (in the _book folder) ready to use as your live site, use the following commands to copy the content into the book-output folder and push that to the gh-pages branch where the live site is:
cd book-output
git rm -rf *
cp -r ../_book/* ./
git add --all *
git commit -m"Update the book"
git push -q origin gh-pages
You can continue to use this last set of commands whenever you have a version in _book that you're ready to push live.

Unable to push Repo from "react-native-firebase-starter" template

I cloned this repo to start my own project
https://github.com/invertase/react-native-firebase-starter
I have made some modifications and got it setup for Firebase, however I cannot push or rename the Repository.
I ran npm run rename and renamed the directory. GitHub still seems to think I am trying to push the orginal repository as my own.
When I try to push I get:
Authentication failed. You may not have permission to access the repository or the repository may have been archived...
How can I keep this template/starter and push a copy of it as my own repository?
I have tried removing all of the inessential files from the Repo and pushing that way. I get the following error:
I expected to be able to use the starter as a starter to get a project up and running... Maybe I am missing something super obvious.
I don't see a .git folder within the root of the react-native-firebase-starter template, perhaps this is causing issues with pushing this template since git needs to know where to point to upstream.
Maybe you could try initializing the template to your personal git repository and seeing if this resolves your authentication issue:
Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files.
Initialize the local directory containing the template as a Git repository:
git init
Add the files in your new local repository. This stages them for the first commit:
git add .
Commit the files that you've staged in your local repository:
git commit -m "Initial commit"
At the top of your GitHub repository ,created in step 1, copy the remote repository URL.
Add the URL for the remote repository where your local repository will be pushed:
git remote add origin <remote_repository_url>
Push the changes in your local repository to your upstream repository contained in GitHub:
git push -u origin master
You should now be able to push this starter template into your own GitHub repository and use it as your own project.
As for the npm run rename command: this is a custom npm run script created by the author of this starter template and it simply runs the rename.js file contained within the .bin directory of the template's root directory. All this command does is recursively rename the files contained within this template project to the new name specified by your input, so I don't think this is causing the issue. I suspect once your project has been initialized properly with git the authentication issue will disappear as it will now point upstream to your personal repository.
Hopefully that helps!

Moving the Git Repository to a Child Folder

I'm using Github with my Wordpress website.
Currently it tracks the parent Wordpress folder, which essentially tracks everything.
I'd like it instead to have a git with only the theme, which is located at wp-content/themes/lighthouse
Is there a simple way to have this repository only be the theme rather than everything in Wordpress? Without having to make a new repository?
If you really don't want to create a new repo, you would simply delete the other folders, and push that new (trimmed) commit back to your existing repo.
Note that you would conserve the other folders history in your past commits.
The techniques mentioned in "Detach (move) subdirectory into separate Git repository" would in effect create a new repo (one with an history only involving the folder you want to keep)
To move git repo to subfolder wp-content/themes/lighthouse while keeping the subfolder’s history, you can refer below steps:
git clone <repo URL>
cd reponame
# checkout all the remote branches locally by git checkout branchname
git filter-branch --subdirectory-filter wp-content/themes/lighthouse -- --all
git push -f --all
Now the git repo moves to the subfolder wp-content/themes/lighthouse and keeps the related histories

Create local git repository based on local repository based on github repository and keep it updated

I have some basic git knowledge but I'm not sure how to accomplish this.
I am trying to clone (?) github WordPress starter theme underscores. The idea is to create a basic framework based (with some modifications) on that repository. Then create other themes with that framework as the base.
So it should look something like:
copy github underscores repository to local
create a local repository my_framework from the underscores one, modifying certain parts of those files always (such as the name) and adding some other files
create new local repositories my_theme1, my_theme2 based on my_framework
The goal is to keep everything updated with any underscores update, while changing and modifying the framework and the themes. Once the content from github is pulled it should keep (or inform) of any updates, but I don't need any change I make locally to go back in the path.
I am not sure which path to follow, and would appreciate any help or pointer.
The goal is to keep everything updated with any underscores update, while changing and modifying the framework and the themes
That is called the triangular workflow:
fork (see "Fork a Repo") the repo automattic/_s
clone that fork locally,
git clone /url/my/fork myfork
add as remote upstream the original repo
cd myfork
git remote add upstream https://github.com/automattic/_s
From there, with git 2.9 or more, configure:
git config --global pull.rebase true
git config --global rebase.autoStash true
Finally, each time you want to update your branches (where you modify your own version of the original repo), do a
git checkout mybranch
git fetch upstream
git rebase upstream/master
Then you can merge that updated branch (after testing it) to your other repos my_theme1, my_theme2, cloned from myfork.
cd my_theme1
git fetch
git merge origin/mybranch
If you want to work locally only, you can skip the fork step and clone directly the original repo.
you should learn about child themes. the concept of it is having a main theme - which gets updated - and a child theme that'll you'll modify, add content, create different templates & styles... everything to your needs.
I'd recommend taking some minutes to read this throughtfully: https://codex.wordpress.org/Child_Themes
Assuming you using a terminal,
cd to the themes directory:
cd [PROJECT]/wp-content/themes
Now clone _s to your project:
git clone git#github.com:Automattic/_s.git [THENE-NAME]
After the clone ends you can start working with your new theme.
cd to theme directory:
cd [THENE-NAME]
and create another remote for your repo.
git remote add [NEW-RENOTE-NAME] [NEW-RENOTE-URL]
From now on, you can push change into your private remote:
git push [NEW-RENOTE-NAME] master
and if you want to get updates from _s repo you can just:
git pull origin master
Good Luck!
you could do something like
git clone https://github.com/Automattic/_s.git
create directory my_framework with mkdir my_framework(if on windows)
cd my_framework
git init
git remote add <_s> <PATH to your local underscore>
git pull(to get latest version of underscore)
again:
mkdir my_theme1
cd my_theme1
git init
git remote add <my_framework> <PATH to your local my_framework>
git pull
Hope this is what you are looking for!
What you want to do is called nested git repo. GitHub does not allow nested repositories. You can use GitSubmodule or subtree. It is done for when projects become bigger.
One copy of underscores will remain as "control".
Second copy of underscores will remain is starting of my_framework. Third copy is copied and modification of my_framework.
You can :
Update underscores repo aka WordPress starter theme underscore master separately
Change in your framework separately
Send pull request for wherever you want to contribute
my_theme1, my_theme2 are not versions but separate softwares. my_theme1 as example can have nth versions. Here are sample steps :
cd ~
mkdir parentrepo
cd parentrepo/
git init .
mkdir child1
mkdir child2
cd child1/
git init .
echo "FirstChildRepo content" > child1repofile.txt
git add .
git commit -a -m "Adding FirstChildRepo content"
cd ../child2/
echo "SecondChildRepo content" > child2file.txt
cd ..
echo "parentrepofile" > parentFile.txt
git add .
git commit -a -m "Adding Parent Repo content"
# verify whether working independently
cd ~/parentrepo/
git log
cd ~/parentrepo/Child1Repo/
git log
# try cloning parent, verify the contents
cd ~
git clone parentrepo/
cd parentrepo/
ls -a
./ ../ .git/ child1/ child2/ parentfile.txt
cd child1/
ls -a
./ ../
Work after this step to clone, update in the way whatever like others written.
You can "auto update" too. Add files named post-checkout & post-merge to .git/hooks directory of the needed repositories and add this into each of them:
#!/bin/sh
git submodule update --init --recursive

jgit tag -f doesn't seem to work

I am trying to move a tag on a remote Git repo. With the git command-line, I can do something like this:
git tag -f <someTag>
git push --tags
But when using JGit, I need to set the force flag on both the tag and the push commands.
git.tag().setName(lastSyncTag).setForceUpdate(true).call();
git.push().setPushTags().setForce(true) // WHY is this needed?
.setRemote(gitUrl).setCredentialsProvider(credentials).call();
If I remove the setForce(true) from the push, the tag is not moved in the remote repository. However, the first time I create the tag, it is properly pushed to the remote repository.
Just wondering if I'm missing something. Any thoughts?

Resources