GIT commands
GIT BASICS
1. Install from http://msysgit.github.io/ and install git installer package
2. During installation, use git bash only as it will not modify our system path variable
3. once installed we get command line version "GIT bash" and gui version "GIT GUI"
4. in order to check the setting of GIT , run the command
git config --list
5. go to location and select git bash here
6. ener command git init(to initialize git)
Adding and commit
===================
1. git add *.txt add all text files in the project
2. git status to see what all files added
3. git commit -m "my first commit"
4. above command commits which needs a commit statement which is mandatory
in case of error unable to auto detect email address
git config --global user.email "test@test.com"
git config --global user.name "test"
Establishing SSH connection with Remote repository
1. ssh-keygen -t rsa
ssh-keygen -t ed25519 -C "test@test.com"
2. .ssh folder is created in users/username/.ssh
one is public and other is privae key
public key contains starting with ssh
3. Login to git hub , go to setting, add ssh, and add the key from step 2
4. From git bash, enter the command "git -T git@github.com" to permanently connecting to git hub remote
committing code to remote server
========================
1. open git bash from the code
2. Enter "git remote add origin https://github.com/hubraman/gitpractice.git"
Note: origin is any name given the remote git url
3. git push -u origin master
1. git clone <<url.git>>
2. git init
This command is used to start a new repository
3. git remote add origin <<url.git>>
This command is used to connect your local repository to the remote server
4. git pull origin development
This command fetches and merges changes on the remote server to your working directory.
5. git fetch origin
list all the branches
6. git checkout <<branchname>
switch from one branch to other
7. git checkout -b <<branchname>> create new branch and switch
8. git branch -m new-name
Renaming the branch
9. git push origin <<oldbranchname>>
Send changes to the old branch of your remote repository:
Continuous integration(When ever build is pushed, jenkins trigger run)
======================================================
1. Go to Mavenproject in Jenkins
2. Click on configure
3. under source code managment select git
4. Enter repository url from git
5. go down and Under Build triggers check Poll SCM and enter 5 starts(*****) and save
Note: git rm -r -f <foldernametodelete>
step1: git clone <<development branch location>> to clone the code in my local
Step2: git init
step3: git remote add origin <<development branch url>>
step4: git fetch origin
Sep5: git cehckout -b <<branchname>>
step6: git checkout <<branchname>>
step7: Optional: git branch -m new-name (in case rename required)
step8: Optional:
a. Rename your local branch:
If you are on the branch you want to rename:
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
b. Delete the old-name remote branch and push the new-name local branch:
git push origin :old-name new-name
c. Reset the upstream branch for the new-name local branch:
Switch to the branch and then:
git push origin -u new-name
Configuration related changes:
Navigate to the location of the Project in your local
To display the user/email
git config --global user.name
gil config --global user.email
Change user and email
================
git config --global user.name <<name>>
git config --gloabl user.email <<email>>
git config credential.modalprompt false --global
Comments