Airo Global Software

Think Beyond Future !

Git

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

How to Use Git in Android Studio?

- Posted in Git by

Git should be integrated into the project.

Check to see if Git is set up.

Navigate to Android Studio > Preferences > Version Control > Git. To ensure that Git is properly configured in Android Studio, click Test.

Allow integration of version control

Assume you've just started a new Android project called MyApplication. Go to VCS > Enable Version Control Integration in Android Studio. If it has previously been integrated with a version control system, this option will be hidden.

Then, as the version control system, select Git.

A default local master branch will be created if VCS is successfully enabled.

To exclude files from Git, add. gitignore.

Two. gitignore files are automatically added when you create a new Android project in Android Studio (one in the project root folder, and the app folder). Git should not contain files such as generated code, binary files (executables, APKs), or local configuration files. Version control should be disabled for those files. Here is the content of my first. gitignore file:

# content of .gitignore
*.iml
.gradle
/local.properties
/.idea/*
.DS_Store
/build
/captures
.externalNativeBuild   
.cxx

Changes are staged and committed

The project is complete and ready for use with Git version control. Go to VCS > Commit to stage and commit your changes.

You will be presented with a dialogue in which you can examine all files that will be added, enter commit messages, and commit. You can uncheck any files that you do not want to be part of this commit.

When you click commit, a popup alerts you that you haven't yet configured your username or email address. Because they will be attached to your commit message, you should always configure them.

"Set properties globally" is an option. I recommend that you do not check this because doing so will result in every git project on your local machine having the same username/email. You may want to have separate usernames/emails for side projects and company projects.

All done — the entire project has now been pushed to Git.

Configure Remote Connections

Go to VCS > Git > Remote to add the project to the remote repository.

To add a new remote, click "+," then enter your remote URL in the URL box. Your local project is now linked to your remote Github repository. You can use Bitbucket, Gitlab, or any other repository in addition to Github. Changes are being pushed to the remote. Go to VCS > Git > Push to push your local changes to the remote repository. The "Push Commits" popup shows which commit will be pushed to the remote-tracking branch. You may proceed with the push.

Obtain the Changes from the Remote

To download the most recent remote changes, navigate to VSC > Git > Pull.

The popup "Pull Changes" appears. I won't go into detail about the pull strategy; simply use the default> strategy and perform the pull.

Collaborate with Branches

Some consider Git's branching model to be its defining feature, and it undoubtedly distinguishes Git in the VCS community. In this section, I'll show you how to use branches in Android Studio.

Make a new branch.

Navigate to VCS > Git > Branches.

The phrase "Git Branches" appears. It displays all of the local and remote branches, as well as the "New branch" option.

Click "New Branch" and give it the name "feature branch."

The other branching possibilities

Assume you're standing near the feature branch. When you expand the menu by clicking on the master branch, you will see many options:

Let me explain each of them in turn:

Checkout: The master branch.

Checkout As: check out a new branch from master. Checkout master and rebase feature branch onto it.

Compare with current: commits that exist in master but not in feature, and vice versa.

Show Diff with Working Tree: Display the difference between the master and the current working tree.

Checkout and Rebase onto Current: Current should be rebased on

Rebase Current onto Selected: Rebase master on the feature has been chosen.

Merge into Current: combine the master and a feature.

Rename: change the name of the master branch.

Delete: remove the master branch from the tree.

You will select the best option based on your requirements.

Display Log History

Select VCS > Git > Show History from the menu.

The history of the currently open file will be displayed in Android Studio,

You can view the entire log history by clicking on the "Log" tab.

You can filter the history here by branch, user, and date, making it easier to find the commit you're looking for.

If you have any doubts about how to use Git in android studio. Don’t hesitate to contact us. Airo Global Software will be your digital partner.

E-mail id: [email protected]

enter image description here

Author - Johnson Augustine
Chief Technical Director and Programmer
Founder: Airo Global Software Inc
LinkedIn Profile: www.linkedin.com/in/johnsontaugustine/

Git Command Line

- Posted in Git by

Git can be used in a variety of ways. Git is compatible with a wide range of command-line tools and graphical user interfaces. All Git commands can only be executed from the Git command line. The commands listed below will assist you in learning how to use Git from the command line.

Basic Git Commands

Here is a list of the most important Git commands that are used on a daily basis.

  • Git Config command
  • Git init command
  • Git clone command
  • Git add command
  • Git commit command
  • Git status command
  • Git push Command
  • Git pull command
  • Git Branch Command
  • Git Merge Command
  • Git log command
  • Git remote command

Let's go over each command in detail.

Git config command

This command sets the user's preferences. The Git config command is the first and most important command on the Git command line. This command specifies the author name and email address that will be associated with your commits. Git configuration is also used in other situations.

Syntax

$ git config --global user.name "ImDwivedi1"
$ git config --global user.email "[email protected]"  

Git Init command

This command generates a local repository.

Syntax

$ git init Demo

The init command will create a new repository from scratch.

Git clone command

This command is used to create a repository copy from an existing URL. If I want to make a local copy of my GitHub repository, I can use this command to create a local copy of that repository in your local directory using the repository URL.

Syntax

$ git clone URL

Git add command

This command adds a file or files to the staging (Index) area.

Syntax

To add one file

$ git add Filename

To add more than one file

$ git add*  

it commit command

The commit command is used in two ways. They are listed below.

Git commit -m

This command causes the head to change. It saves or snapshots the file in the version history and adds a message to it.

Syntax

$ git commit -m " Commit Message" 

Git commit -a

This command commits any files added to the repository with git add, as well as any changes made since then.

Syntax

$ git commit -a 

Git status command

The status command displays the current state of the working directory and staging area. It shows which changes have been staged, which have not, and which files are not being tracked by Git. It provides no information about the committed project history. You must use the git log for this. It also shows which files you've modified and which you still need to add or commit.

Syntax

$ git status

Git push Command

It is used to transfer content from a local repository to a remote repository. The act of transferring commits from your local repository to a remote repository is known as pushing. It's similar to git fetch in that it imports commits to local branches while pushing exports commits to remote branches. The git remote command is used to configure remote branches. Pushing has the potential to overwrite changes, so it should be used with caution.

The git push command can be used in the following ways.

Git push origin master

This command pushes changes from the master branch to your remote repository.

Syntax

Git push -all

This command commits all branches to the server repository.

Syntax

$ git push --all

Git pull command

The pull command is used to get data from GitHub. It downloads and merges changes from the remote server into your working directory.

Syntax

$ git pull URL  

Git Branch Command

This command displays a list of all the branches in the repository.

Syntax

$ git branch 

Git Merge Command

This command is used to merge the history of the specified branch into the current branch.

Syntax

$ git merge BranchName

Git log Command

This command examines the commit history.

Syntax

$ git log

If no argument is passed, the Git log displays the most recent commits first. We can limit the number of log entries displayed by specifying a number, such as -3 to show only the last three entries.

$ git log -3

Git remote Command

The Git Remote command connects your local repository to a remote server. You can use this command to create, view, and delete connections to other repositories. This command does not allow you to access repositories in real-time.

If you have any doubt about the git command line. Don’t hesitate to contact us. Airo Global Software will be your digital partner.

E-mail id: [email protected]

enter image description here

Author - Johnson Augustine
Chief Technical Director and Programmer
Founder: Airo Global Software Inc
LinkedIn Profile: www.linkedin.com/in/johnsontaugustine/