A Using the Git Command Line Interface
You can use the Git command line tool to commit files to the Git repository and generate SSH keys.
On Windows, you can use the Git Bash command line tool to commit files. You can download Git Bash (version 1.8.x or later) from http://git-scm.com/downloads
.
On Linux and Unix, you can install Git using the preferred package manager. You can download Git for Linux and Unix from http://git-scm.com/download/linux
.
Customizing the Git Environment
If you are using Git for the first time, use the git config
command to customize the Git environment.
To set your user name and email address, set the user.name
and user.email
variables.
Examples:
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"
To set the proxy server or disable SSL, set the http.sslVerify
and http.proxy
variables.
Examples:
git config --global http.sslVerify false
git config --global http.proxy http://www.testproxyserver.com:80/
To know the value of a variable, use git config <variable>
.
Example:
git config user.name
Tip:
Use thegit config --list
command to list all environment variables and their values.
Using Git Commands
You can use the Git command line tool to clone the hosted Git repository, create and manage branches, commit, and push files to the hosted Git repository.
If you are new to Git, here are some of the common Git commands that you will use. For more information about a command or to learn about other Git commands, see http://git-scm.com/docs
.
Clone the Git Repository
Use the git clone
command to clone the hosted Git repository to your local system.
HTTPS example:
git clone https://john.doe%40oracle.com@developer.us.oraclecloud.com/developer1111-usoracle22222/s/developer1111-usoracle22222_myproject/scm/developer1111-usoracle22222_myproject.git
SSH example:
git clone ssh://usoracle22222.john.doe%40oracle.com@developer.us.oraclecloud.com/developer1111-usoracle22222_myproject/developer1111-usoracle22222_myproject.git
Note:
If you are using the SSH protocol, create an SSH key and add it to Oracle Developer Cloud Service. See Generating an SSH Key.Create a Branch
Use the git branch
command to create a branch in the Git repository.
Example:
git branch new_branch
Note:
To list all existing branches , entergit branch
.
Checkout a Branch
Use the git checkout
command to switch to (or checkout) a branch.
Example:
git checkout new_branch
Note:
You can use thegit checkout -b
command to create a branch and switch to it immediately.
Example: git branch -b new_branch
Add Files to the Cloned Git Repository
Use the git add
command to add new files to the cloned repository.
Examples:
git add readme.txt
To add a directory and its contents, navigate to the directory and use git add .
Commit Files to the Cloned Git Repository
Use the git commit
command to save your changes and commit all added files to the cloned Git repository.
Example:
git commit -am "Sample comment"
To associate an issue with a commit, add Task-URL: <issue-url>
in the comment.
Example:
git commit -am "Sample comment Task-URL:https://john.doe%40oracle.com@developer.us.oraclecloud.com/developer1111-usoracle22222/s/developer1111-usoracle22222_myproject/task/4"
If the commit is successful, the SHA-1 checksum hash of the commit is added to the issue. Open the issue in Issues page of the Oracle Developer Cloud Service web interface and verify the SHA-1 checksum hash in Commits under Associations.
Merging Branches
Use the git merge
command to merge a branch. Before you merge a branch, check out the branch you wish to merge into.
Example:
git checkout master
git merge new_branch
Push Updates to the Hosted Git Repository
Use the git push
command to push updates from the cloned Git repository to the hosted Git repository.
Example:
git push origin master
Pull Latest Updates from the Hosted Git Repository
Use the git pull
command to incorporate changes from the hosted Git repository to the local repository.
Example:
git pull origin master
More Git Help
To display the Git help index, enter the following command.
git help git
To display help for a particular command, enter the following command.
git help <command>
Generating an SSH Key
SSH keys are used to configure and connect to a project's Git repository using an SSH tunnel. You can associate an SSH key with your account from your account preferences page. Note that only RSA keys are accepted as SSH keys.
Migrating to Git
You can use Git commands to migrate your project source code from other version control systems, such as CVS and Subversion, to Git.
Migrating from CVS
To migrate your project source code from CVS, use the git-cvsimport
command. For more information about the command, see http://git-scm.com/docs/git-cvsimport
.
Migrating from Subversion
To migrate your project source code from Subversion, use the git svn
command. For more information about the command, see http://git-scm.com/docs/git-svn
.
Migrating from other version control systems
To migrate your project source code to Git from other version control systems, see the Git Book at http://git-scm.com/book/es/v2/Git-and-Other-Systems-Migrating-to-Git
.