Category Archives: Git

Moving a git repository to new server

If you want to move your git repository from one server to another or say from github.com to gitlab.com or from your own server to another server, follow below steps to transfer your repo.

Step 1 – Create a bare clone  of your existing git repository

Step 2 – Now cd into the newly created directory ‘your-existing-git-repo-link.git‘  and fetch all branches

Step 3 – We have all the branches on our local machine, lets push it to new server

That’s it, you have shifted your git repo.

Replace local branch with remote branch entirely

Simply:

Assuming that “origin/master” is your remote branch you want to reset to. This updates your local HEAD branch to be the same revision as origin/master, and --hard will sync this change into the index and workspace as well.

ref – http://stackoverflow.com/questions/9210446/replace-local-branch-with-remote-branch-entirely

Rename branch for both local and remote Git repositories

 

How to remove multiple deleted files in Git repository

To delete files which are visible in git status can be deleted by using this simple command

You can use these commands also

This will ONLY remove the deleted files from the git.

It could be also be used for adding ONLY modified files also.

These commands also works on gitbash for windows.

ref: stackoverflow.com

Removing – LF will be replaced by CRLF in git

In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have a LF. It’s nothing to worry about.

— (stackoverflow)

To deactivate this use following command

 

 

Useful git resources

List of useful git resources, that I have come across.

37 single’s

https://37s.backpackit.com/pub/1465067

Git refcard on DZone

http://refcardz.dzone.com/refcardz/getting-started-git?uid=835453&nid=21049&token=08354531112134474811f
Git – the simple guide

http://rogerdudler.github.com/git-guide/

Git reference

http://gitref.org/creating/

Getting started about version control

http://git-scm.com/book/en/Getting-Started-About-Version-Control

Git in 15 minutes

try.github.com

Add other useful resources known to you in the comment below 🙂