Solving Committing Issue between R Studio and Github
In the normal development process, you will create a repo (the repo in this article is located at Github), followed by the cloning process or download as full directory into your localhost. It is much easier and straightforward. There won’t be any issues especially if your scrum master or release manager is a well trained person in handling branching, merging, and releasing code using git.
However, in most cases, especially for a full-stack developer who did everything on its own, you may encounter an issue if:
You created a project in your localhost first using R Studio and set Git as your SVN through your project setting
Then you created the repo at the GitHub
Finally, upon ready, you run command to sync with your GitHub
The following is the command that you use/execute and the result of running the command:
% git remote add origin [your GitHub report url]
% git pull origin master
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From [your GitHub report url]
- branch master -> FETCH_HEAD
- [new branch] master -> origin/master fatal: refusing to merge unrelated histories
and you see the last sentence .. ERROR
Then, based on google, you followed with the following command
% git push -u origin master
and you get the following response (or similar)
To [your GitHub report url]
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘[your GitHub repo url]'
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.
Next, you try to pull again to get the latest branch based on the previous error by running the command to pull again
% git pull origin master
And the result is still not promising
From [your GitHub report url]
- branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories What are you missing or wrongly done? I won’t be able to tell you the missing or wrong steps, but I’m sharing your step to overcoming the problem.
STEPS
Go to you localhost directory where you created the project
In that directory, you should find a file name .gitignore & folder .git
Delete both by running rm -fr (if you are using windows, the command might be different)
Next, init your project file again by running the command git init. You shall see the following message appear after executing the command — Initialized empty Git repository in [your project path]
Followed by adding the remote repo by running the command git remote add origin [your GitHub repo url].
The followed by git add . (make sure there is ‘.’ at the end of the command). It tells the git to add all directories in the remote repo to your local.
Followed by git pull origin master. If succeed, you shall be able to see the following result:
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From [your GitHub repo url]
- branch master -> FETCH_HEAD
- [new branch] master -> origin/master Finally, run git push -u origin master to verify again. You shall see the following result to indicate it is successfully integrated between your local repo and your Github repo and R Studio shall be able to interact perfectly with GitHub. Branch ‘master’ set up to track remote branch ‘master’ from ‘origin’. Everything up-to-date Once you have done all the steps, go ahead to your R Studio and perform Stage -> Commit -> Commit Message -> Push to complete the process. Refresh your Github page and you shall see all of your local files at your GitHub repo.
If you find this useful, you can buy me a coffee :) @ https://www.buymeacoffee.com/masteramuk
Top comments (0)