Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Wednesday, October 29, 2014

GIT : Branching

Hi,

Git Branching is the basic need in Git Version control.

Here i like to share the steps to manage the branch in your application repository.

Step 1: I am assuming initially you have "master" branch in your application then you create another branch i.e. "development" then run the below command:


# git branch development


# git checkout development  

//it will switch the branch into "development" branch

Step 2: Now your are in fresh "development" branch. Then push your "master" branch code into the "development" branch.

# git push origin development

GIT clone form specific branch

# git clone <git-repo-url> -b <branch-name> --single-branch

Ex:
Suppose i had to take git clone of specific branch like development-fix not all others then my command would be

# git clone git@bitbucket.org:project/project-name.git -b development-fix --single-branch






  

Wednesday, March 26, 2014

GIT Tag

Hi,

Create GIT Tag on your project is useful to keep track of your project release.

Step to create the Tag in GIT are:

1.  # git tag -a V2 -m "tag 2"

2. # git push origin V2

Where, V2 : relate the tag name

If you want to switch into previous tag

# git checkout tag-name

where tag-name, is the tag no where you want switch back/fro to the release.


To get list GIT tag
# git tag


To cloning the branch or tag
# git clone --branch tag_name repo_url

Where,
tag_name : GIT tag no.
repo_url : GIT URL


To get the checkout from the Tag
# git checkout tags/tag-name

I hope above GIT tag command is useful to manage tag.






Thursday, October 17, 2013

GIT : Basic Command

1. How to color the Git console in Ubuntu?

# git config --global color.ui auto

The color.ui is a meta configuration that includes all the various color.* configurations available with git commands. This is explained in-depth in git help config.


color.ui: This variable determines the default value for variables such as color.diff and color.grep that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the --color option. Set it to always if you want all output not intended for machine consumption to use color, to true or auto if you want such output to use color when written to the terminal, or to false or never if you prefer git commands not to use color unless enabled explicitly with some other configuration or the --color option.


2. How to keep password in memory?
# git config --global credential.helper cache
which tells git to keep your password cached in memory for (by default) 15 mins
# git config --global credential.helper "cache --timeout=3600"
which tells git to keep your password cached in memory for 3600 seconds

3. Get diff in file
# git diff
will return the file differences

4. How to resolving file conflicting after Git Pull?
Step 1> Identify which files are in conflict (Git should tell you this)
Step 2> Open each file and examine the diffs; Git demarcates them. Hopefully it will be obvious which version of each block to keep. You may need to discuss it with fellow developers who committed the code.
Step 3> Once you've resolved the conflict in a file, then apply below command in console
# git add file-name
Step 4> Then commit the conflict
# git commit -m "Conflicts Resolved"

5. How to add new file on Git?
# git add
# git commit -m "new file added"


6. How to check the file status in your repository?
# git status

7. How to push you committed file on the remote server?
# git push origin master

8. How to get the Git Update from remote server?
# git pull origin master

9. How to increase Git performance?
# git gc
will give significant speed on your local repository.
Basically, git-gc : it is for cleanup unnecessary files and optimize the local repository.

10. How to get the Git Log?
# git log

11. How to get log on specific file?
# git log "file-name"
ex:
# git log test.txt

12. How to get file from Git of specific version?
# git show commit-no:file-name

ex:
# git show abcdefghijklmnop:test.txt

13. How to know file list from Git of specific version?
# git show commit-no --name-only

ex:
# git show 0ba1a6177178f77cd711bfe1db43fac80f70f3e2 --name-only

14. How to use GUI visualize for Git log?
Please install gitk tool in your OS
# sudo apt-get install gitk
It will install in your OS, after that you are able to view the git log in GUI, where everybody easy to identify the following:
  • Commit with the name, and respective committed files
  • file change in every commit
  • Text search in committed file
  • beautiful file comparison
  • file navigation  
 Run below command to run GUI interface:
# gitk

15. How to remove file/folder from GIT
if you want to remove file, then

# git rm file-name
if you want to remove folder, then
# git rm folder-name -r

# git commit -m "your message"
#git push origin master

16. How to change message after GIT commit
# git commit --amend -m "New commit message"