Intelij: "Files commited" but not showing in Github? - java

I have built my Project using "gradlew build idea"
I linked my project to GitHub and performed my initial commit using the instructions on the Website.
However when I commit changes from my change lists it says "files commited" yet when I check my GitHub repository they are not there?
What do I need to do to configure to Intelij with my exact Repository on GitHub?

However when I commit changes from my change lists it says "files commited" yet when I check my GitHub repository they are not there?
In order to see your files on the remote repository you have to push them.
Once you commit the file are only inside your local repository.
Here is the basic flow that you will need to follow:

GitHub is a git storage website, which you use as a remote. git repos can be completely local if needed. If you have never pushed before, run:
git remote add origin https://github.com/user/repo.git
git push origin master
Don't commit using intellij. Use the command line.
git add .
git commit -m "Your commit message"

All the changes you commit are saved in Local. So, you need to push the changes from Local to Remote. For this, right click on master in Local and you can see Push option.
Please refer the attached screenshot.

Related

How can I work on one java project and push my code to multiple git branches as I progress?

I am currently doing a project for a bootcamp and I'm having some trouble. I need to demonstrate that I can use githhub. They want to see that I separate my crud functions onto different branches. So I created a repo using git bash, created a dev branch, with 4 branches coming off of that; create, read, update, delete. I checked out onto the create branch and pushed my create method coding to the create branch. I checked out to the read branch to push my read method code and the files disappeared from eclipse when I checked out to the read branch.
Do I need to push to the create branch and then pull to the read branch to continue working on my read methods?
Hope this makes sense to anyone reading
git checkout create
git add .
git commit -m
git push (gave me an error, prompted me to push upstream?)
git checkout read
// this is where my file disappeared from the package explorer in eclipse.
// my code was successfully pushed to github but I cant continue working on it when I checkout to the read branch
// my next step is to write my read functions, checkout to the read branch and push my code to the branch
I think the way they're wanting to see this done would be to
pull the code
git checkout -b [feature branch name]
Make your partial edits, commit and push
switch back to your base branch, git checkout [root branch]
Repeat at step 2 with you next set of edits.
Then issue pull requests to your root branch for your feature branches.

Cannot pull origin dev due to unrelated conflict in Git

I pull a branch (let's say issue-100) from origin for review and after review I switched to local dev branch without modifying this issue-100 branch. There are some conflicts with this branch, but I did not touch it and just create a new branch after pulling dev branch from origin. But, interestingly, Git gives "Automatic merge failed; fix conflicts and then commit the result." messages. I just followed these steps:
git checkout dev
git pull origin dev
--> gives error, then I abort merging in IntelliJ
git branch
git branch -D issue-100
git checkout dev
git pull origin dev
--> gives error, then I abort merging in IntelliJ
So, I did not push issue-100 to origin, but it gives error. How should I fix this problem?
Conflicts are showing up because of this discrepancy between your local dev and remote dev. If local dev is supposed to be just like remote dev, you should put the branch right there:
git checkout dev
git reset --hard origin/dev # before running this, make sure there are no pending changes laying aroind your working tree as they would be lost
Now local dev and remote dev are exactly the same (content and history). Everything should be back to normal.
There's this question in my head about why people should not use a local copy of a shared remote branch, but it is waaaaay broader than your question in point and I happen to hold an opinion that is against common wisdom (I think people should not keep a local copy of a remote shared branch but..... that's just my opinion).

Pulling and Pushing Repo

I am very new to using Github. I am only used to writing code in my local device. I need to pull a repo off of github, create a new file inside of the repo (Which will have my .java program), and push it back to github. I have looked online but the explanations are pretty confusing to me (As a beginner).
Download and install the git command line tool:
https://git-scm.com/downloads
If you're on windows, there's a git bash many people prefer over cmd. On any other operating system, just use the terminal/cli.
Once installed, first you'll want to clone the repository. You'll find the URL on the repository page after clicking the green "Clone or download" button:
git clone [url]
https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
Then you'll add your file to be tracked by git:
git add [filename]
https://git-scm.com/docs/git-add
Then you'll commit your changes.
git commit -m "Added a file like a champ!"
https://git-scm.com/docs/git-commit
Then you'll push your changes, provided you have permissions to push.
git push [remote name] [branch]
Use git remote -v to view your remote names and URLs. Your remote name is default "origin" at first so if your branch name is "develop," it would be git push origin develop
https://git-scm.com/docs/git-push
The alternative, and the correct way to do it, is to fork the repo, make your changes, commit and push your changes to your remote repo, then create a pull request on the original repo's branch:
https://help.github.com/articles/about-pull-requests/
Pull requests are requesting the other person pull your changes into their branch. This gets into merging and such:
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
I provided documentation links in an effort to persuade you to check them out. Both github and git provide excellent documentation. There are also countless git tutorials online, many are interactive and really help you learn this brand of source control.
Check to make sure you have git installed locally first:
Run in your command line:
git --version
If it returns a git version, then go to the github repository and copy the path like so:
In your command line type git clone followed by the path (paste it in) like so:
From the above example:
Press return or enter. The repository will be cloned and set up for you locally.
After the cloning is finished, you can cd directly into the repository. In the above example I would type:
cd cordova-runner
Assuming you have been given contributor rights from the repository's owner, you can from there make changes, branch, add, commit, and push back to the repository. If you haven't been given rights, you can do the same process, but fork the repo first.
I hope this helps.
Git clone <--Url to repository-->
Git checkout <--branchname-->
Create your file
Git pull (to again sync the repo with remote repo)
Git add
Git commit -m "write comment here"
Git push
All you need to do is
svn co https://github.com/path/to/repo
... create your new file ...
svn add your_file
svn commit your_file -m "Message about new file."
and then you're done.

How to deploy a Java web aplication on OpenShift or Git?

I have created a web site using NetBeans IDE by File -> New Project -> Java Web -> Web Aplication using apache-tomcat-7.0.67 as my Server.
The website consits of 3 .jsp pages, 1 servlet and 1 javaBean and json.org (extension is .jar)
Now I'm trying to deply it on http://app1-lolcheck.rhcloud.com/ but I have no idea how both to use git or Openshift.
I've installed git, ruby and OpenShift rhc Client Tools.
Finally I have already done what this video says (but using Tomcat 7 (JBoss EWS 2.0)) : https://www.youtube.com/watch?v=vbvOQ2gopwo
So what should I do?
Victor,
I will try my best to answer your question in the general steps needed rather than the exact steps which will require some configuration.
If you log into your OpenShiftAcount and go into your developer portal you can go into your applications settings. Among other things, listed there will be git address.
What you will need to do is, assuming you have downloaded git, set it up following these steps:
Getting started with git
Then you need to go into your project directory and initialize the git there using:
git init
then add everything in your project folder except what's included in .gitignore (more details on the link that i provided you)
git add .
then commit everything
git commit -m "Some commitment message here."
now you need to add the application git address to your git's origin
git remote add origin [git address like git#github.com:user/gitname.git]
then you deploy using
git push origin
There are a lot of things I did quick and dirty and the actual configuration of the projects for rhc will need to be done by changing some settings file or in some cases procfiles. With everything that you need to get used to, please use this as a guideline for solving your problem.
A good crash course on git is going to be very helpful in any development work with version control and especially so with web development since so much deployment is done using git.
I am by no means a git expert, not even close to it, but I do use it in android development, web development and recently even in arduino programs just becasue of version controlling it offers.
To remove existing remote origin
git remote rm origin
Then you can add it one more time using the git remote add I mentioned above.
Git and OpenShift are two different things. Git is a version control software, like CVS or SVN. OpenShift is a PaaS provider, like Google App Engine. OpenShift is using Git to manage the deployment.
Your link shows that you've successfully created and deployed a running web app. The next thing you want to do is clone the source from OpenShift to your local disk, make changes and do a git commit and push your changes to the OpenShift cartridge. Your cartridge already has scripts that will be automatically be triggered to deploy your changes.
Follow these steps:
Netbeans > Team > Git > Clone:
Give your Repository URL. something like ssh://app1-lolcheck.rhcloud.com/~/git/.... (Hint copy it from your application page on openshift...see on right side under "source code")
username will be automatically filled
provide private/public key (you can get from settings menu on openshift website)
select master branch and in next step give parent directory where you want to clone and finish. Now copy your project contents in that directory...
right click on project in netbeans, click git > Commit
Then right click again your project > Git > Remote > Push. Done
Application will be deployed within few minutes.

GIT in eclipse: unable to push, after checking out an old version and change that

I am using GIT in eclipse. I needed to checkout some older version, so I opened the history in eclipse and right click on the one I wanted and clicked "checkout". I applied the changes I wanted to make, and at the end I used GIT -> commit, and after inserting the description pressed "commit and push". However it said "There is nothing to push". The push button is inactive as well, and when I checked the bitbucket web page related to my source, this last commit is not recorded! what can I do to push this version into bitbucket?
You have a detached head situation. You have to create a temporary branch and merge this branch back.
This should do the trick:
git branch my-temporary-work
git checkout master
git merge my-temporary-work

Categories

Resources