Tuesday, 30 June 2015

adding .gitignore file to existing repository


Follow the below mentioned steps if you want to ignore certain files from your git repository.
  1. Navigate to the location of your Git repository.
  2. Type "touch .gitignore" and press enter to create a .gitignore file.

Note: If you are adding .gitignore to an existing repository. 
Execute git rm --cached name_of_file to remove files that you do not want to be tracked. This is required because .gitignore ignores files that were not tracked before (by git add)

Example:

If you want to ignore all log files from your logs directory. Enter below line to your .gitignore file

logs/*

Thursday, 2 January 2014

how to pull from an existing git repository

how to start from scratch by pulling branches from an existing git repository
 
mkdir /path/to/your/project 
cd /path/to/your/project 
git init 
git remote add origin ssh://git@bitbucket.org/username/bbreponame.git
 
 
Then check out as local branches
git checkout -b LocalName origin/remotebranchname 

Wednesday, 4 September 2013

changing git remote url


Go the project folder for example:

cd /home/vickrant/project1

then edit the git config file like:

sudo vim .git/config

In this file you can change the url to whatever repository you like to change it to. Save and close the file. Now you can do git pull from the new URL.

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://vickrantearnest@bitbucket.org/project1.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "develop"]
        remote = origin
        merge = refs/heads/develop
[branch "master"]
        remote = origin
        merge = refs/heads/master