What is the step or process of adding a file from my RStudio to one of my github repository? I searched in the internet. But, they provide vague steps on how to do it using RStudio. Can someone help me on how to add my file from RStudio to one of my github repo just by using the git in RStudio?
the first thing is to have an Rstudio project, and for that to be git enabled.
do you need help with that aspect ? or subsequent steps ?
My friend I need both aspect and subsequent steps for beginner like me. I am still confused on how to do it. Though, I watch tutorial video. Most of the videos do not provide the small details for beginners like me. I tried to commit some of my files to the repository of my github account using Rstudio via Git Version Control. But, it gives me error, like this one below.
To GitHub - alhakimdata/case-study
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'GitHub - alhakimdata/case-study'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I have 3 repositories from my github account. I made it 3 because one of it is for my case study. The other one is for my data analysis practices/exercises. The other one is for projects in the near future.
What if I only want to choose some of my files to be pushed to my github. How can I do it?
Can I commit and push my codes from RStudio to my github repositories using a personal access token by generating a token from my github account? Is it one of the ways on how to commit and push it to repos?
It seems you dont need help with what i initially asked as you are already beyond that and couldnt be asking the questions you are if you werent....
This issue here comes with its own hint as to howbto address it, you hqve been advised to pull before your next push
C:/Program Files/Git/bin/git.exe pull
error: The following untracked working tree files would be overwritten by merge:
README.md
Please move or remove them before you merge.
Aborting
Merge with strategy ort failed.
That message above is the error I get when I pull it. Can you help me with this. I really need a help on how to use RStudio on committing and pushing my code to my github repositories.
I was able to push it using the git push -f origin main in the RStudio terminal. But, the problem is that, it was put to the wrong repository. How can I put my code to the right repository I created? I have 3 repositories. How can I change the repository in RStudio?
Do I need to change the repository of my RStudio? So that I can commit and push my code to the right repository in my github account? I am confused already, my friend. It's been hours thinking what should I do. Tried to commit it using the git push -f origin main. But, it was pushed to the wrong repository. It should be commit and push to the right repository of my github account.
I think you need to study the use of Git before trying to push to various repositories. One good resource is
https://git-scm.com/book/en/v2
but I'm sure there are many good sources of information.
I mostly use Git from the command line, so I may be unaware of easy ways to do things through the RStudio GUI.
In RStudio, you can look in the menu Tools -> Project Options -> Git/SVN to see which repository you project is tracking. You can push to other repositories from the command line. In the Terminal in RStudio, run
git remote -v
and you should see information about the repository listed under Tools -> Project Options -> Git/SVN. You can add repositories with git remote add
. See the book I linked or other documentation. You can push to a particular repository with git push RepoName BranchName
. Those are just hints. Please study some documentation.
Thank you for the reply. I appreciate it. I will try to read the link you provided. But, of course. I was thinking that I only want to learn how to commit, push my code in my github repos. Then, learn how to edit it back to RStudio, learn how to delete files from repos. I guess, however, I need to learn all about the git. I was thinking to learn those things that I needed as a new data analyst, not the whole process of it. Because it will take time and not all are needed. But, thank you for your effort on replying.
By the way, can I ask you about the initialized folder of my files. Do I need to keep on creating new folder (blank folder from my pc). Then, initialize it. And then, used it to all files under that one folder? Or should I create one folder. Then, I'll create sub folder inside of that folder for every project I make?
Think of every project in RStudio (menu File -> New Project) as its own repository. When RStudio sets up the project, it will either make a new folder or you can direct it to use an existing folder. That folder should be dedicated to materials for that one project. RStudio will handle initiating the Git files if you select to use Git with the project. Similarly, any remote repository on GItHub or any other location should be dedicated to that project.
You do not need to study the entire book that I linked. I suggest you start with the first three chapters.
Thank you! I appreciate it. Thank you to those who replied to my post. I am new to R and Git. I want to change a career to become a data analyst. That is why I joined in this community because I wanted to learn the ins and outs. So, I am your new neighborhood, spidata analyst.
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.