Local alternate for Git with RStudio? - r

My colleague & I are starting on a R project, we both would be working simultaneously & interchangeable components of the model we are building. We can not use Git, as we do not want to put our code online, also it is not allowed by the organization. We also do not have a server of our own, what we have is some common shared drive. Is there a way, we can use a tool like Github/SVN completely locally, where both of us can push our code.

There are two options you can manage your R project with git repo.
Option 1: setup remote git repo in the shared directory
You can setup a remote git repo in the shared directory, and then add the remote repo as a remote for your local git repo, then you can push and push from the remote git repo. Detail steps as below:
First, in an empty folder of the shared directory (assume in \\share\path\gitrepo), execute:
git init --bare
Then add the remote repo as a remote for the local repo you are working.
Assume the local git repo (R project) is opened in R Studio, so you can add remote in R Studio terminal window or through git command line:
git remote add origin \\\\share\\path\\gitrepo
Note:
The count of slash \ in the remote repo url.
And the pull and push button is still disabled after adding remote repo since the local branch (maste) has not tracked the remote branch (origin/master).
Then you can commit changes and push to remote repo first time by:
git push -u origin master
After that (local master is tracking origin/master), the pull and push button will be enabled after refresh the git tool bar. And can pull/push by clicking the buttons afterwards.
Option 2: host the remote git repo to third-party private repo
If it’s ok for you to hosted your git repo to third-party, and do not let everyone has read permission, then you can create a private git repo in the third-party organization.
For bitbucket, it’s free to create private git repos, so you can host your git repo there.

Related

How to download a Nexus Git-LFS repository

I succesfully pushed a git-lfs repo to a Nexus repo and I can see two git blobs on the remote server. I'm wondering if is there the possibility to clone this repo. I tried different ways:
git clone http://..../reponame/info/lfs
git clone http://..../reponame/
creating a new git-lfs repo and pulling (no error, but no pull is actually done)
There's no reference to this topic in the doc here https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/git-lfs-repositories
What's the right way to clone/pull this type of repository from Nexus?

adding version control Git to my already deployed wp website

I have a wordpress website on hostinger and im trying use version control Git on it without downloading the files locally but i have no idea what to do or where to start ! my goal would be pushing to github as if im working locally (but im not the files are on the server and i dont want to download them ) please Help.
You need to initiate a git repo for the files on a server and add a GitHub repo as the remote for this. Then you can push files from your Hostinger server to GitHub. To do this, you will ideally need SSH access to your hosting. This seems possible with Hostinger depending on your hosting plan. See how to login to hostinger account via SSH.
Once you've logged into your hosting account via SSH:
Change into your website's folder using cd /path/to/folder
Start a new git repo in this folder using git init
Add all your existing files using git add .
Commit the files you've added using git commit -m "Commit message"
Create a new repo on GitHub (if you haven't already)
Add the empty GitHub repo as the remote for the files on your server using git remote add origin git#github.com:username/repo-name.git
You should now be able to push files to GitHub using git push origin main or git push origin master
Good day.
Unfortunately you can not push at once from hostinger to Github.
I have 7 steps for you to push all code to the GIT server:
1)Install github locally
Download github
2)Copy the files of your website to local directory
3)Open cmd.exe on windows follow to your catalog with Website files and run next command to initialize new git repository locally
git init
4)Add files to your locall repo
git add .
5)Add commit
git commit -m "First commit of website"
6)Create remote repo link for your website on github.com and copy link to the next command(replace CAPS)
git remote add origin https://github.com/USERNAME/REPO_NAME.git
7)Push all files to Github
git push origin master

How to synchronize Local Repo with Github and Remote server after API KEY blocked SMTP server

I have made my private repository public so my SMTP server blocked my account because I had the API KEY inside one of the files (.env - it is a Symfony project).
I followed the steps on git hub Remove sensive data to remove sensitive data up until step 8 included.
All the commands were executed on the cloned repository (I am not even sure if this was correct).
The cloned repo and github repo is clean of sensitive data.
On my remote server (Scaleway) I had deleted a file before doing these steps (mistake).
Remote server :git status gives me this :
On branch master
Your branch and 'origin/master' have diverged,
and have 84 and 84 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: public/uploads/images/logo_linxea-5f82e58f42913.png
no changes added to commit (use "git add" and/or "git commit -a")
If I try on remote server git rebase -- interactive as suggested Here I get the following :
Cannot rebase: You have unstaged changes.
Please commit or stash them.
Questions:
I am not sure if I have to continue working now on cloned repo (on local), original local repo or Remote repo for the steps 9 and 10.
How to sync the remote repo with github repo, and the local original repo with the github repo without resending all the removed sensitive information.
I need to keep the .env file on the Remote Server so my emails keep working.
Well I tried something seems to work
On Remote Server :
git reset --hard HEAD
Then
git clean -df
Then
git rebase --interactive (where I just exited) Got this message:
Successfully rebased and updated refs/heads/master.
Then recreated .env file on remote server because it was deleted in the process

How to upload local RStudio Project to Github including commit history?

I have a RStudio Project with a history of git commit history.
I would like to upload this Project incl. the git commit history to Github and see the commit history on Github.
I can create a new repo on Github and commit from RStudio, but this would not include
past commits i have locally.
What i tried:
I can upload a RStudio Project / package. But (all?) the git files are in a hidden Folder (OS: Windows 10) and i cant upload this hidden Folder to Github (get a warning / error message "This file is hidden").
Looked through https://happygitwithr.com/rstudio-git-github.html
All you should need would be to:
add an origin to your local repository referencing the new (empty) GitHub repository
push
That is:
git remote add origin https://github.com/<you>/<newRepo>
git push -u origin master
# or
git push --mirror
Add your GitHub url to the remote using the Terminal tab then push. https://articles.assembla.com/en/articles/1136998-how-to-add-a-new-remote-to-your-git-repo

Git - Can't Push - "! [remote rejected] master -> master (Working directory has unstaged changes)"

I am trying to set up a "simple" git workflow for a Wordpress installation that has a local version, a staging version and a production version. All I want to do is make changes locally and push from local to staging and from local to production. At first I thought this would be a simple task. I have been able to initialize the repository, add the two remotes "staging" and "production", initialize git on the remotes and push changes from my local version to the staging and production servers normally using the commands:
git add .
git commit -m "some changes"
git push staging master
git push production master
However, at some point during my work something changed, and while I am still able to push to Staging, now I am unable to push to the Production server without getting the error:
! [remote rejected] master -> master (Working directory has unstaged changes)
When I do "git status" it says:
On branch master
nothing to commit, working tree clean
After reading the answers to several SIMILAR BUT DIFFERENT questions on Stack Overflow I have tried the following:
git pull staging master
git pull staging master --rebase
git pull production master
git pull production master --rebase
I also tried executing this command on the remote servers
git config --local receive.denyCurrentBranch updateInstead
I have already completely re-created the servers and repositories a few times just to re-install git entirely from scratch, but this problem keeps happening after a while and at this point Git is actually HURTING my workflow instead of helping it. If anyone has any insight into what my mistake is, it would be much appreciated!
I had similar problems, pushing to a non-bare remote repo where I wanted the working copy files to be checked out immediately.
My remote was configured with receive.denyCurrentBranch updateInstead, but it still refused to accept pushes at unpredictable times.
Git 2.4 added a push-to-checkout hook, which can override such push failures.
I wrote a short script based on the example in the githooks documentation.
#!/bin/sh
set -ex
git read-tree --reset -u HEAD "$1"
I installed this script in .git/hooks/push-to-checkout in my remote repo.
Note that this script overwrites the working copy in the remote — it does not attempt to merge any changes to those files.
That's because I want the working copy to simply reflect the files in the repo.
Making a git bare repo is the best practice to push to.
You could push to a non-bare one... but only if you are not modifying files on the destination side while you are pushing file from the source side. See push-to-deploy.
But the best practice remains to add a post-receive hook (as in my other answer) in order to checkout in an actual folder all the files you have received.

Resources