working on it ...

Filters

snippets
18
followers
56
Published by libby

Git

Basic, not so basic, and usually helpful git commands.
Sort by

Found 18 snippets

    public by lbottaro  2461  15  7  1

    How to git diff a file version excluding space differences

    This git command allows to get differences on local modified file ignoring space or blanks as changes
    >git diff --ignore-space-change myFile.txt            

    public by lbottaro  2341  3  6  1

    Get the url that a local git repo was originally cloned from

    Once a repo is cloned, this snippet shows how to list the url path a local git repository was originally cloned from.
    C:\Users\testRepo>git remote show origin
    
    * Output
    * remote origin   
      Fetch URL: git@github.com:/git/repo/path/testRepo.git  
      Push  URL: git@github.com:/git/repo/path/testRepo.git  
      HEAD branch: master
      Remote branches:                        

    public by lbottaro  1970  1  6  0

    Git list local and remote branches

    This command is useful to figure out what are the local and remote branches on a repository. Option -a will show all local and remote branches, while option -r shows only remote branches.
    > git branch -r
    * remotes/origin/master
      remotes/origin/dTest
      
    > git branch -a
    * master
      origin/1-2-stable
      origin/2-0-stable
      remotes/origin/master
      remotes/origin/dTest                        

    public by Tech_JA  2001  0  6  2

    Push an existing Git repository

    First steps to use Git
    cd existing_git_repo
    git remote add origin your_git_url
    git push -u origin master

    public by Tech_JA  2346  1  6  4

    Create a new Git repository

    First steps to use Git
    mkdir your_local_dir
    cd your_local_dir
    git init
    touch README.md
    git add README.md
    git commit -m "my first commit"
    git remote add origin your_git_url
    git push -u origin master

    public by Tech_JA  3380  0  6  3

    Set user and email address

    First steps to use Git
    git config --global user.name "your user name"
    git config --global user.email "your email address"

    public by markcl  3097  7  5  2

    Change Directory and File Permissions Properly For Linux Web Server

    Sets file permissions to 644 and directory permissions to 755.
    find [YOURDIR] -type d -exec chmod 755 {} \;
    find [YOURDIR] -type f -exec chmod 644 {} \;

    public by markcl  3387  7  5  1

    Git Clone into non empty directory

    git init
    git remote add origin PATH/TO/REPO
    git fetch
    git reset --hard origin/master  

    public by lbottaro  341335  3  7  1

    How to checkout the latest tag of a Git repository

    This simple bash script allows to automatically checkout your local git repository on the latest tagged version available on the remote repository. The script assumes to be run from your local repo. The command 'git rev-list --tags' lists the tags IDs in reverse chronological order, getting the very last one on top. The command 'git describe
    # Get new tags from the remote
    git fetch --tags
     
    # Get the latest tag name
    latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
     
    # Checkout the latest tag
    git checkout $latestTag  

    public by lbottaro  6060  5  8  1

    How to check if a Git remote repository is available in python

    This simple python code shows how to check if a given Git remote repository is available. The code invokes the git command 'git ls-remote' on the remote URL path as subprocess with Popen and checks the exit code, using the communicate() method. The command exit status is stored into the 'returncode' property. A value not-equals to '0' mean
    from subprocess import Popen, PIPE, STDOUT
    
    p = Popen(["git", "ls-remote", "git://remote_path"], stdout=PIPE)
    output = p.communicate()[0]
    if p.returncode != 0:
      print "Command failed ["+str(p.returncode)+"]"        
    • Public Snippets
    • Channels Snippets