9.4 KiB
Git Operations - Complete Reference
Table of Contents
- Overview
- Git Views
- Repository Management
- Basic Operations
- Branch Management
- Git Stash
- Authentication
- Corporate Git Repositories
- Gerrit Integration
- Troubleshooting
- Documentation Links
Overview
SAP Business Application Studio provides integrated Git capabilities through built-in tools. Key points:
- Only HTTPS connections supported (SSH not available for on-premise)
- Built-in web proxy for on-premise Git access
- Two interface options: Simplified Git View and Advanced Git View (Source Control)
Best Practice: Always connect projects to Git repositories for long-term persistence.
Git Views
Simplified Git View
Default view for basic Git operations. Access via Simplified Git icon in activity bar.
Capabilities:
- Clone repositories
- Create and manage branches
- Commit, pull, push operations
- Conflict resolution
- Pending changes management
Advanced Git View (Source Control)
Full-featured Git interface. Enable by right-clicking activity bar → deselect Simplified Git → select Source Control.
Components:
| Section | Purpose |
|---|---|
| Menu Toolbar | Toggle views, commit, refresh, history, more actions |
| Message Section | Enter commit descriptions |
| Staged Changes | Files ready for commit |
| Changes | Modified but unstaged files |
| Amend Section | Modify existing commits |
Status Bar Indicators:
*- Unstaged changes (dirty)+- Staged changes!- Conflicts↑↓- Ahead/behind commit counts
File Status Indicators:
- A - Newly staged file
- U - Unstaged file with changes
- M - Modified file
- C - Copied (blue) or conflicted (red)
- D - Deleted file
Visual Change Indicators (Editor Gutter):
- Red triangle - Deleted lines
- Green bar - Added lines
- Blue bar - Modified lines
Repository Management
Cloning Repositories
Method 1: Terminal
git clone [https://github.com/YOUR-USERNAME/YOUR-REPOSITORY](https://github.com/YOUR-USERNAME/YOUR-REPOSITORY)
Method 2: Command Palette
- Open Command Palette
- Type
Git: Clone - Enter repository URL
- Select destination folder
- Provide credentials if required
Opening Projects
Projects appear in file explorer within workspace or as standalone folders.
Basic Operations
Stage and Unstage Changes
Stage All: Click stage all icon in Changes section
Stage Individual: Click + icon next to file
Unstage All: Click unstage all in Staged Changes
Unstage Individual: Click - icon next to file
Commit Changes
- Stage files
- Enter commit message
- Press
Ctrl+Enteror click checkmark
Commit Types:
| Type | Description |
|---|---|
| Standard Commit | Save changes to local repository |
| Commit (Amend) | Add changes to the last commit |
| Commit (Signed Off) | Add sign-off line certifying authorship |
Push Changes
Incorporates all unsynced committed changes into remote branch.
git push
Or use Source Control menu → Push
Pull Changes
Downloads and merges remote changes into local repository.
git pull
Or use Source Control menu → Pull
Fetch Changes
Downloads objects and references without merging.
git fetch
Then merge or rebase manually.
Merge Changes
Incorporate all changes from one branch into another.
- Checkout target branch
- Source Control menu → Merge
- Select source branch
Discard Changes
Removes all changes from active branch. Warning: This cannot be undone.
View Diffs
Double-click modified file to open diff editor showing:
- Index version (left)
- Working tree version (right)
Branch Management
Create Branch
git branch <branch-name>
Or click branch name in status bar → Create new branch
Switch Branch
git checkout <branch-name>
Or use Command Palette: Git: Checkout
List Branches
git branch # Local branches
git branch -a # All branches including remote
Default Branch
For migrating from master to main, refer to Git documentation for default branch configuration.
Git Stash
Temporarily store work-in-progress changes.
Stash Operations
| Operation | Description |
|---|---|
| Stash | Record current state and return to clean working directory |
| Pop Stash | Apply and remove single stash entry |
| Pop Latest Stash | Apply and remove most recent stash |
| Apply Stash | Apply stash but keep it in stash list |
| Apply Latest Stash | Apply most recent stash, keep in list |
| Drop Stash | Remove single stash entry |
Note: If conflicts occur during pop, entry remains in stash. Resolve conflicts manually, then drop stash.
Authentication
Basic Authentication
Two credential management approaches:
| Method | Description |
|---|---|
| Credential Cache | Cache in memory for short period |
| Credential Store | Store indefinitely in dev space file |
Security Recommendation: Use Personal Access Tokens (PATs) instead of passwords. Refresh PATs regularly.
OAuth Authentication (GitHub)
- Connect to GitHub triggers popup with verification code
- Copy code and open GitHub
- Paste and authorize code
- Configure persistence (per session or per dev space)
Preferences:
sapbas.git.github.oauth- GitHub.com OAuthsapbas.git.github.enterprise.oauth- Enterprise GitHub
Azure DevOps
Generate PAT from Azure DevOps and use as password during clone.
Corporate Git Repositories
Prerequisites
- Cloud Connector installed and configured
- Destination created in SAP BTP cockpit
- Administrator configuration complete
Cloud Connector Setup
| Setting | Value |
|---|---|
| Back-end Type | Non-SAP System |
| Protocol | HTTPS |
| Internal Host/Port | Your Git system's network details |
| Virtual Host/Port | Can match internal settings |
| Principal Type | None |
Resource Access:
- URL Path:
/ - Access Policy: Path and all sub-paths
Destination Configuration
ProxyType = OnPremise
WebIDEEnabled = true
HTML5.DynamicDestination = true
HTML5.Timeout = 60000 # Optional
GitHub Enterprise OAuth
Create OAuth app with Device Flow enabled, add GitHubEnterpriseClientID property to destination.
Certificate Requirements
Upload Git server certificate to Cloud Connector if using certificate-based authentication.
Gerrit Integration
Gerrit provides code review before commits reach the repository.
Configuration Steps
-
Enable Gerrit: File → Preferences → Settings → Extensions → Sapbas → Check "Whether gerrit is enabled"
-
Add Properties (from Gerrit administrator):
- hookPath
- protocol
- hostname
-
Clone Repository
-
Commit Changes: Use Commit (Amend)
-
Push to Gerrit: SOURCE CONTROL menu → More Actions → Push to Gerrit
Troubleshooting
HTTP 502 Error on Clone
Error: fatal: unable to access '[https://...':](https://...':) Received HTTP code 502 from proxy after CONNECT
Solution: Set up Cloud Connector and configure Git to work with Gerrit.
Refresh Destinations
After creating destinations, refresh in dev space:
curl [http://localhost:8887/reload](http://localhost:8887/reload)
Use Correct URL
Always use the exact same host and port as defined in the destination URL property.
Branch Default Name Migration
When migrating from master to main:
git branch -m master main
git push -u origin main
Documentation Links
Last Updated: 2025-11-22 Source: https://github.com/SAP-docs/sap-btp-business-application-studio/tree/main/docs