Basics of GIT – [WebIDE Integration with GIT]
This article will help consultants, developers or data architects who are working on SAP Commissions Project must follow these steps to implement Git Process and most important and essential way of keeping the code clean when working with multiple team members.
Note: To understand this article, you need to know the basics of Git.
What is Git?
Git is nowadays the way to keep your projects safe! Your own small project or the projects of big teams inside companies.
A short version of the explanation is, Git will keep track of all the changes of your project. It will show who did make a change, what is changed, and when it changed.
You can always go back to an earlier state of the code if you want to.
Git is not only suitable for programming projects, but also very suitable for other types of files. Design files for example!
First, we have to install Git in order to use it. Git is available for Windows, Mac, and Linux.
Set up your git credentials
In order to get your name and email right with every commit you do. You need to set the git name and git email.
Set your git user.name
Open the terminal and type git config –global user.name “Your Name” to set the name you will be using on your machine for Git. If you remove the —global option, then this name will only be set in that repository you are in.
You can check it with the git config user.name command. If you did it right, your name will appear.
Set your git user.email
Open the terminal and type git config –global user.email email@example.com to set the name you will be using on your machine for Git. If you remove the —global option, then this name will only be set in that repository you are in.
You can check it with the git config user.email command. If you did it right, your email will appear.
Start a Git project
There are a few ways to start a project with Git.
- Start with initializing Git in a local folder on your computer
- Create a new project on Github, Bitbucket, Gitlab, or any other company that is hosting Git repositories.
Let’s start with initializing Git in a local folder on your computer.
Open the terminal and type git init and hit enter.
With this command, there will be a hidden .git/ folder. In this folder, all your changes will be saved. Eventually also all the changes others will make to this repository if you pull those changes. But git pull will be in another episode.
It is also possible to start your project by creating the repository remotely. Remote is the external service/company that is hosting your Git repository on a server.
Github is the most popular for a large amount of opensource projects. Bitbucket is most used by people who want to keep there code private or bigger companies that are also using other Atlassian software. Gitlab is a newer service, but I heard good sounds about it.
Of course, there are a lot more or you can host your own. But your codebase should be somewhere on a server where it is safe! You can get a copy of the whole repository by typing the git clone followed by the git-repository-URL.
Like this for example:
Git terminologies and most common commands
Repository is a directory where your project/files are stored which are used to interact with Git.
commit this is when you make one or more changes to a file in git.
branch this is creating a new line of development. This is mainly used to continue working without messing with the mainline of development.
git commit this is the command used to commit changes to your git repo. Commit contains a message which is used to describe what changes you’ve made.
staging area this is where git will put/store files while waiting for you to commit the file containing the changes.
SHA this is a unique ID number that is given to each of your commits.
git init this command is used to initialize your project into a repository.
git clone this command is used to copy an existing repository to your computer.
git checkout this command takes you to a different branch in your repo.
git branch this command is used to create a new branch.
git checkout -b this command is used to create a new branch and automatically switch to it.
git status this command shows you the current status of your repo like files which are yet to be committed or the branch you are currently in.
git push this command sends all your commits to the Github/Gitlab/Bitbucket repo you have created.
git pull this command fetch all your files from your repo and integrate them with your local repo. I mostly use it to make sure everything is up to date and working correctly.
git add this command is used to add files from the working directory to the staging area.
git diff this command is used to display the differences between two versions of a file also you can see changes that are yet to be committed using this command.
git merge this command is used to combine changes from different branches together.
git revert this command is used to a specific commit. It is usually followed by the commit SHA to indicate which commit you to want to reverse
Let’s start using GIT in SAP Commissions Project
SAP Developers – WEBIDE – Step by Step WebIDE Integration with Git Repository
Git in SAP Web IDE – The Basics
- Create the repository in your GitHub account.
- Clone the project on your machine.
- Create a branch before making changes.
- Make your changes.
- Commit and push your changes.
- Open a pull request to Support team.