Sunday, March 24, 2019

GIT Repository commands for Developers

//rameshgit12
//Rajammal12
Install the Gitbash shell on windows and create GITUB account on your own

Initialize the repository
git init -->initialize the repository
Reinitialized existing Git repository in C:/Users/Nethra/git/.git/

Add your remote server to the origin
git remote add origin https://github.com/rameshgit12/Spark.git
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (master)

Clone the remote server datas to your local
$ git clone https://github.com/rameshgit12/Spark.git
Cloning into 'Spark'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
Log on in GIT Bash file:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (master)

Give the Username and Email credential
$  git config --global user.email "rameshexpnet@gmail.com"
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (master)
$  git config --global user.name "rameshgit12"

Verify the status 
git status
showing red color for untracking files
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        readme.txt
nothing added to commit but untracked files present (use "git add" to track)

Move to the staging server
git add readme.txt
it is moved to the staging server

Verify the status again
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
        modified:   readme.txt
no changes added to commit (use "git add" and/or "git commit -a")

Commiting the changes
git commit  ==> commiting the staging server

git commit -m "change 3"
m means that message

Verify the history of changes whoever commit the changes
git log
$ git log
commit e6a27850fbc122dce1bc1f774af141aa1647174f (HEAD -> Mybranch, origin/Mybranch, master)
Author: rameshgit12 <rameshexpnet@gmail.com>
Date:   Sun Mar 24 22:54:22 2019 +0530
    message 4 and 5
commit 0a8d7f3830904462fb799f88c00b717f3213dde5
Author: rameshgit12 <rameshexpnet@gmail.com>
Date:   Sun Mar 24 22:49:19 2019 +0530
    latest changes

Added all changes in the staging server:
git add .

We can give like below pattern
git add *.html
touch .gitignore
git add .gitignore

Create your own branch
git branch mybranch
git checkout Mybranch  -->switched to the Mybranch
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (Mybranch)

Push the changes to the GITUB remote repository:
$ git push https://github.com/rameshgit12/Spark.git Mybranch
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 533 bytes | 76.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'Mybranch' on GitHub by visiting:
remote:      https://github.com/rameshgit12/Spark/pull/new/Mybranch
remote:
To https://github.com/rameshgit12/Spark.git
 * [new branch]      Mybranch -> Mybranch



git commit -m 'new updates'

Switch the branch to Master
git checkout master

Merge the Mybranch1 branch to master branch
$ git merge Mybranch1
Updating 951cbec..05e45c4
Fast-forward
 file2 | 0
 file3 | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file2
 create mode 100644 file3

Eg.,
git commit -a -m 'change 6'

git remote

git clone url

git remote add origin

cd fluentgard
git remote -v
git fetch origin
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (Mybranch)

Pull the GITUB remote changes into our local
$ git pull origin master
From https://github.com/rameshgit12/Spark
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/git (Mybranch)
$ git pull origin Mybranch
From https://github.com/rameshgit12/Spark
 * branch            Mybranch   -> FETCH_HEAD
Already up to date.

Delete some files in GITUB and pull it again, Now we can match the datas between local and remote GITUB

git push origin master  
$ git push origin master -f
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (10/10), 802 bytes | 89.00 KiB/s, done.
Total 10 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To https://github.com/rameshgit12/Spark.git
 + b4c67eb...951cbec master -> master (forced update)







No comments:

Post a Comment

Python Challenges Program

Challenges program: program 1: #Input :ABAABBCA #Output: A4B3C1 str1="ABAABBCA" str2="" d={} for x in str1: d[x]=d...