For the project demo purpose, I am going to use some filler text from the hipster Ipsum website, hipster Ipsum provides us with the dummy text for our demos.
Now, let's start with the project.
Open Gitbash command prompt. check our root directory by passing
Here I have already created a folder called project hence
cd into it. Create a new repository using
git init <repository name>
Here am creating repository as a fresh-project for demo purpose. when you pass
git init fresh-project Git will create a repository with the above-mentioned name.
it will take you to the repository, where you are going to make some operations over here.
ls command, it won't show you the list of files in it, hence pass
ls -al it will show you all the folders and files present in the repository including .git folder as well.
- If you wanted to see files inside the .git folder you can use
cd .git/ and
ls command it will show you all the hidden files.
- Now come back to your working directory by passing
cd .. command.
- To see the Status of the working directory pass
git status command, it will explain to you that, we are on the master branch where a master branch is default branch and nothing to commit yet because still, we do not add any file to the staging area.
- Now to get some filler text open hipster ipsum in the browser and click on the beer me, now you got some dummy text copy the text as you required.
- Get back to the Gitbash and create a text file as
Notepa++ hipster.txt and press enter.
- Now a notepad++ page will open, paste your copied dummy text here and save the file by pressing ctrl+s and exit (ctrl w) and exit from the main page with alt+4.
git status, it will show you an untracked file hipster.txt because it is still in the working directory as shown in the above image.
- Let us add this file to the staging area by using
git add hipster.txt command and check
git status now Git will return as, you are on the master branch and having new file hipster.txt, and changes to be committed.
- Do commit as
- A Notepad++ page will open, it will ask you to write some commit message, so enter some message and save then exit using the above commands.
- You can see the same commit message in the command prompt.
- Now check for the
git status, it will say, your working directory is clean, in the below image u can see some text file which I had for some other project but you do not get confused.
- Go back to your working directory
- And give
pwd it will take you to the current folder.
ls Git display fresh-project folder. now, you can remove this folder by using
rm -rf fresh-project/
- To check whether it is removed or not, you can pass
In this Demo Project, we are going to learn about how to add Git to an Existing Project using Initializr. Initializr provides us with the bunch of source codes and hence we will add Git Source control over that Project.
Initializr: It is an HTML5 Templates Generator to help people getting started with the new project by using HTML5 Boilerplates.
Now let us first download the Initializr zip file.
- Open your browser and navigate to page https://www.initializr.com
- Once Initializr home page will open then select Bootstrap
- Then it will show you H5BP optionals, select everything as the default just to get more files and click on the Download button.
- Once it completes downloading jus check in your download stack and copy the zip file name.
- Now open Gitbash Command prompt select your working directory and pass below command to unzip the zipped file.
$ unzip ~/Downloads/initializr-verekia-4.0.zip
ls command to see what's inside the initializr folder.
- Move an initializr file to another folder, here am moving it to a web-project folder. Then give
pwd it will take you to the web-project folder
- Again give
ls command, then Git will list all the files from unzipping the zipped file.
- Let's consider these are your project files and add Git source control to this project.
- Now initialize a repository and use your current folder as your working directory and use Git's
git init command and press enter.
- A new repository has created now and give
ls -al to see all the files, with the other files you can see .git/ files as well.
git status, Git tells us that it's on the master branch, and no commits yet as the files are untracked, means files are still in the working directory.
- So in order to add all these files to the tracking area, use command
git add .
git status it reflects the so many project files in the staging area.
- Now add a commit message and pass commit command as
git commit -m "your commit message"
- If you do a
git status , Git tells that it's on the master branch and nothing to commit hence working directory is clean.
- Once again give
ls command so that it will list all the files including .git folder also.
- This project is actually controlled by git so until .git folder stays in the repository the project is managed by Git so now remove .git folder by using
rm -rf .git and give
ls command to check whether the .git folder is deleted, hence we had removed all the traces of Git, managing this project.
- Now go back to your project folder web-project and remove this folder as well by using remove command
rm -rf web-project
- So your working directory is clean.
This article explains you, how to add Git in Android Studio. Git is an open source version control system.
It is a best practice to use version control software for development and also Git is the best choice amongst the software like CVS, Subversion, and ClearCase.
So before adding Git to the android studio, First learn how to install Android studio into your Operating system.
- Navigate to https://developer.android.com/studio page.
- Click on the Download Option.
- Now it will take you to the android studio page, there select the Android studio package with respect to your system platform.
- In my case, I selected the Windows 32 bit.
- Once you click on, it will show you the download page, click on the I have read and agreed to the above terms and conditions.
- Now it will highlight the download android studio for windows 32 bit, hence click on that and it will start downloading.
- Once the download has completed, just go to your downloads and the software which was downloaded was in a zip format. so, select and extract the file from the zip.
- Now our operating system will start installing it.
- You will see a welcome page, in that click on Next.
- Then, Select UI theme page will open, click on Next button.
- Another page called SDK Component setup page will open, here you can select the components you wanted to update/install, do not select anything as of now and click on Next button.
- One More page, verify setting page will open, this will show you whether you wanted to review or change any installation settings and then just click on Finish.
- Once you verified, it will start downloading the components.
- once it's done with the download just click on the finish button and thus Android studio has installed in your operating system.
- Now let's start with adding Git in Android Studio, as follows:
- First, install the Git in your system.
- Open the Android Studio, open the project in the android studio and then select settings under File.
- Now select the Version control under Settings.
- And also select Git under version control.
- After that, Click on the Test button to test the path to Git executables. If it is successful, a message is shown as everything is ok, else navigate to git.exe from where you installed Git and test again.
- You can ensure that Git is properly configured in Android Studio.
To share the android project in Github we should create a Git account in Github first. because the Github provides an online service for hosting the project by using the Git.
Now let's start with adding an android project to Github. Before that, you should have a Github account, if not then learn how to create a Github account.
- Open Android Studio and select the Github under version control. by selecting the settings under File (File-Settings-Version control-Github) in the same order.
- Once you select Github, it will ask you for login credentials, give your username and password which was used to create your Github Account and click Ok.
- Now you can see Github image appearing on the Android studio window, with its user name.
- Then go to VCS and select the import into version control under this select Share project on Github.
- Now a small dialogue box will open, in that enter your new repository name, description and click on the share button.
- Now another one window will open and check all the files in order to add files for initial commit and click on Add.
- Now the project has been uploaded into the Github repository, once uploading is finished, if it is successful, you can see a message on android studio window as shown below.
- Click on the link given in that message, it will take you to the Github Repository.