In this tutorial,
I will walk through the step by step instructions to deploy your
locally created maven project into github also how to manage your git
repository. There are plenty of good articles available in the
internet regarding using git. Here In this article I am
consolidating, those important steps needs set up remote git
repository in github.com. For convenience to the readers and easy to
understand the content, I attached the screen shot for some of the
steps.
- First create your maven project in JBDS or eclipse. In this tutorial I am using JBDS-7.1.1
- Ope your terminal, navigate to the maven project folder
- Type the following command and enter (I assume , you already installed git in your machine)git init
- Create your git repository in github.com, do that you need to have your github account, if you already have one you can log into github and create your repository.
- Copy your git repository http origin url
- Go back to you terminal, type the following and entergit remote add origin https://github.com/sprabakkar/test.git
- Type following command and entergit add .
- Type the following command and entergit commit -m "initial commit"
- Type the following command and entergit push -u origin master
when you your new
file or changes to remote repo, you have to provide your github used
id and
password
- If you accidentally push the wrong files or folder to github, don't worry, follow steps to fix it....
- Type
git rm -r dir-name-to-remove
and enter
if you face any problem delete the files using the above command, use the following command to force the function
git rm -rf
dir-name-to-remove
and enter
Type
git commit -m "Remove
d
directory"
and enter
Type
git push origin master
and enter
If you want to keep the folder or files locally and want to remove from the remote git repo use the following command
git rm -r --cached
dir-name-to-remove
Type
git commit -m "Remove
d
directory"
and enter
Type
git push origin master
and enter
If you want to permanently prevent those files added to remote git repo in future commit use
.gitignore
file.
Create
.gitignore
Git uses a
file named .gitignore to exclude files that you never want to include
in the repo, such as generated class files.
- In your local filesystem, navigate to the maven project folder.
- With your favorite text editor, create a new file in that folder named .gitignore.
- Add those file you want to block from commit in this new file and save it:for example,target/bin/.settings/.classpath.project*.zip*.log
No comments:
Post a Comment