Git clone into a non-empty directory?

We can do with the following steps that worked for me:

1st step: git init

// 2nd step: for https
git remote add origin

// OR

// 2nd step: for ssh
git remote add origin

3rd step: git fetch

4th step: git pull origin master

Another alternative but I did not try:

git init
git init add origin PATH/TO/REPO
git fetch
git reset origin/master
git checkout -t origin/master

Later I also tried this process and below is my problem and solution …

You might get the error “fatal: A branch named ‘master’ already exists.
Then it seems you are in the branch “master”. Then we can do the following extra steps to make it works…

#to add all the files except the untracked files
git add -u

# commit files from server to git
git commit -m “files from server to git”

# push all the files to git
git push origin master

After that you make lose some files on git since we pushed the files from server. In that case you may add the missing files later from vai server to git or vise versa.

For more: More explanation


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s