Showing posts with label git basic. Show all posts
Showing posts with label git basic. Show all posts

Monday, November 19, 2018

Git Tags - what, why, when and how

Git TAGS - What | Why | When | How
Today We will learn: -------------------------------
1. What are tags / releases
2. Why should i create TAGs
3. When to create TAGs
4. How to create TAGs in git

create | show | publish | delete

Step 1:
Checkout the branch where you want to create the tag
git checkout "branch name"
example : git checkout master
________________________________________________________


Step 2:
Create tag with some name
git tag "tag name"
example : git tag v1.0
git tag -a v1.0 -m "ver 1 of .." (to create annotated tags)
________________________________________________________

Step 3:
Display or Show tags
git tag
git show v1.0
git tag -l “v1.*”
________________________________________________________

Step 4:
Push tags to remote
git push origin v1.0
git push origin --tags
git push --tags (to push all tags at once)
________________________________________________________

Step 5:
Delete tags (if required only) to delete tags from local :
git tag -d v1.0
git tag --delete v1.0

to delete tags from remote :
git push origin -d v1.0
git push origin --delete v1.0
git push origin :v1.0
to delete multiple tags at once:
git tag -d v1.0 v1.1 (local)
git push origin -d v1.0 v1.1 (remote)


________________________________________________________

Checking out TAGS

 We cannot checkout tags in git
We can create a branch from a tag and checkout the branch
git checkout -b "branch name" "tag name" example :
git checkout -b ReleaseVer1 v1.0
 ________________________________________________________
Creating TAGS from past commits
git tag "tag name" "reference of commit"
example : git tag v1.2 5fcdb03




source

how to see git log and diff

source
How to see logs and diff in Git

git log --stat


  • git log --stat
to show all where file was changed.
how may lines are modified added or deletion like this.


 new_file.txt | 1 +
 1 file changed, 1 insertion(+)


  • git log -p
You will see like this.
    new added p

diff --git a/new_file.txt b/new_file.txt
index 8646659..b5f7bcb 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1 +1,2 @@
 this is new file
+now added p word
\ No newline at end of file


Different between commit 

after change the file , where is changed to show this. you need to check differ.
  • git diff
 $ git diff
diff --git a/new_file.txt b/new_file.txt
index b5f7bcb..7f6d181 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1,2 +1,4 @@
 this is new file
-now added p word
\ No newline at end of file
+now added p word
+changed
+another
\ No newline at end of file


Only changes file show

  • git diff --word-diff
$ git diff --word-diff

diff --git a/new_file.txt b/new_file.txt
index b5f7bcb..b11d6b6 100644
--- a/new_file.txt
+++ b/new_file.txt
@@ -1,2 +1,4 @@
this is new file
now {+new+}  added p word
{+changed+}
{+another+}

Fetch and Pull


when you work a branch with team you need checkout branch.
before work or push you need to pull first.

if anyone change their branch you must pull first and then push.

but if you fatch all branch to your repository, you can write 'git fetch origin master'

  • git pull origin master
  • git push origin master

  • git checkout -b dev
  • git checkout -b dev-amirul
  •  
  • git checkout dev
  •  
  • git branch
  • git push origin dev.