I have started to use Git package inside RStudio . It seems to work fine for Master branch. But adding another branch, you can commit any changes through the GUI but the "push" button doesn't work. Any thoughts how this can be fixed? I can do the push through the terminal but not GUI.
As per Hadley's explanation:
If you try to synchronise this [new] branch to GitHub from inside RStudio,
you’ll notice that push and pull are disabled. To enable them,
you’ll need to first tell Git that your local branch has a remote
equivalent:
git push --set-upstream origin <branch-name> After you’ve done that
once, you can use the pull and push buttons as usual.
Related
While I am trying to push on GitHUb from rstudio it is stuck and is not reflecting on Github
There might be some mismatch in the settings that I have configured watching tutorials.
Error Screenshot
Git Settings
Rstudio Options
GitHub Account Settings
Repository Settings
I was facing the same issue while following one of the courses online. I don't know exactly what causes this issue.
Problem: Exactly the same with every setting as shown in the screenshot.
The solution:
in RStudio, click on the "Tools" menu and select "Shell"
Run the following command: git push
it might ask you for your git username and password. Supply this
information, make sure it is correct
hopefully, the push is successful, then you can close the window
Now make some more edits to some files so that you have new content to
push
Click on the "push" button in RStudio and this time the push should
work
This is not my solution I found it here: https://stackoverflow.com/a/45804117/5677883
I am struggling with Github and Rstudio. I don't know Github very well and I find the commands very confusing.
I read that Github preferred default branch should now be main and not master anymore. So I created my repository and followed instructions for creating a main branch.
First question:
do I need to use main as default branch to create an R package for download? I see that devtools::install_github still has master as default, so I am puzzled because Hadley and his group are usually very reliable.
I set Rstudio both local and origin to main. However, no matter what I do, Rstudio will always push to master (and recreate it if I deleted it) with the command push origin HEAD:refs/heads/master. (why is this command using HEAD:refs... and not just push origin master? If this is the problem, how do I change Rstudio's default?)
I tried git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main from bash to no avail. I can push to main manually with git push origin main but then Git starts nagging that master is behind. This command really pissed off git git config --global push.default main.
Second question:
How do I set Rstudio to push to main (or to both master and main)?
I'm coding in Rstudio and my workflow is along these lines:
make a new branch using Rstudio's UI
add some code or fix a bug
commit code when I'm satisfied and push to GitHub
merge the new code into the master on GitHub
pull the latest master code from GitHub into Rstudio using it's UI
delete any local/remote branches via command line (because Rstudio doesn't have the functionality and doesn't sync with GitHub when it comes to remote branch deletion)
This might not be the most efficient way of doing things (I'm new to git) but it works well enough except for the problem I'm having. Twice now, seemingly at random, I've created a new branch, worked on it and when I've gone back to check something in the master they are identical. The code changes I've made in the branch have already synced with the master.
This is what the last two lines of the History look like:
git history
independant_erp_norm_regressions is the last branch I merged into the master while preprocess_select_global_pars is the current branch which is syncing to the master unduly.
I'm at a loss as to what is going on because I'm doing the same thing as I usually do and haven't been able to find any similar questions on stackoverflow.
Any help would be greatly appreciated (as well as any ways in which I can streamline my workflow).
Ok thanks for the responses guys, as per Tim's reply I decided to commit the changes made to the new branch via Rstudio's UI and check in command line to see what happened behind the scenes. (After that I thought I would do an entire branch/merge via command line to see if the problem persisted or if it was a Rstudio bug). So just before committing the changes Rstudio's git interface showed that Master and my branch were still in sync up to and including having staged files selected together. After committing I used "git show-branch" in command line and it showed that only the correct branch had a new commit, this was mirrored in Rstudio's Git history interface and after merging via GitHub all is well. So it seems like it was just an Rstudio-git bug of sorts.
In RStudio, if you are dealing with a directory that contains a large number of files, and you want to commit and push the recent changes (that you made on all of them) to your repository, the GUI Git component gets super slow and practically doesn't work. Any idea?
Of course you can ignore the GUI and stick to the command-line Git forever, but if you don't want, a quick jump to the command-line git would solve this problem for now.
The temporary solution that I found is as follows:
Click on the blue-gear icon on the GIT panel, inside RStudio.
Select Shell (a terminal window will pup up!)
Write the add and commit command in the terminal:
{ATTENTION: The following command will commit changes on ALL files! You may want to use what is appropriate for your situation!}
git add -A && git commit -m 'staging all files'
Now you can go back to the GUI Git, and click on push button. All files that you staged in the terminal window, will be pushed up to your repository.
My workaround today was to...
create a man1/ directory in my RStudio project (after force-closing and
relaunching RStudio a few times after I had done something that caused it to hang again),
include man1/ in .gitignore,
move just about everything in man/ to man1/,
delete the .git/index.lock file in the repository,
futz around with RStudio, until it was responsive enough to make the (small) commit of files from man/,
pull and push, so that the remote main was once-again fully synched
copy some files from man1/ to man/, commit these
repeat and rinse of steps 6 and 7, until there's nothing left in man1/
Delete man1/ and its entry in .gitignore
My recipe above isn't one-size-fits-all... for example, you may have run into a "diff is too large" difficulty with RStudio because of a single oversized file, rather than (as I had) with "too many" small files. If you're trying to commit a monstrously-big set of diffs from a single file... you should be including this file in your .gitignore, rather than expecting it to be version-controlled without any difficulty by git. Also, if you're locking up RStudio's Git-interface because of "too many" files being committed simultaneously, your first port of call should I think to commit directories one at a time (but do be sure to push & pull after each commit).
And... I'm not going to complain about this defect in how RStudio interacts with git!
Instead I'll close with some kudos. After just a few days of futzing around with RStudio, I'm finding it to be so much easier than what I remember about hacking on S via emacs in the early 1990s. RStudio handles just about everything (especially the ROxygen documentation workflows) than the emacs/eSS setup that I had been struggling to get fully operational earlier this month.
I'm also impressed with how R has developed since the last time I looked at it -- about 20 years ago! The semantics lurking in corner cases are still very "surprising", to put it mildly ;-) But I do appreciate how it has maintained compatibility with the truly-bizarre and primitive semantics of S while allowing its power-users (which will surely never include me!) to write expressively, elegantly, and with an appropriate balance between concision and the write-only alphabet-soup of APL and its ilk (https://en.wikipedia.org/wiki/Write-only_language)
My enterprise has a Git repository. To make changes, I have to make changes in my forked repository and then make a pull request.
I primarily use RStudio, so I have enabled its integration with Git. I can make changes to my forked repository and then push, pull, sync, etc. The problem is that I still have an additional step of logging into GitHub and making a pull request for my forked repository. Is there a way of doing this from RStudio?
I too use RStudio for R development and I do not believe there is a way to do this. The reason is because this is more than just adding code to a branch, you're requesting a management feature to take place which is pulling part of your code into another branch of the code base. RStudio appears to be limited to pulling, syncing and committing. Likely you need to use a separate, more full featured GitHub client.
This could be done via the GitHub API, which could be executed from an R package using the httr or curl package, after which such a package could have an addin for RStudio, which would let you check everything using a nice Shiny app!
Now we only need to look for someone who wants to develop this… Can’t seem to find it (Jan 2022).