Breaking

Followers

Tuesday, 5 January 2016

Adding an existing project to GitHub using the command line step by step

Putting your existing work on GitHub can let you share and collaborate in lots of great ways.


Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.

Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).

Change the current working directory to your local project.

dalveer@Nayak:~$ cd /var/www/afeather-way/sites/all/modules/

dalveer@Nayak:/var/www/afeather-way/sites/all/modules$ cd delete_user

Initialize the local directory as a Git repository.

"git init"

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git initInitialized empty Git repository in /var/www/afeather-way/sites/all/modules/delete_user/.git/

Add the files in your new local repository. This stages them for the first commit.

"git add ."

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git add .

Commit the files that you've staged in your local repository.



git commit -m "First commit"

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git commit -m "First commit"
[master (root-commit) 6bd307a] First commit
 7 files changed, 4019 insertions(+)
 create mode 100644 README.txt
 create mode 100644 README.txt~
 create mode 100755 delete_user.info
 create mode 100755 delete_user.info~
 create mode 100755 delete_user.module
 create mode 100755 delete_user.module~
 create mode 100755 trade_form.info~

At the top of your GitHub repository's Quick Setup page, click  to copy the remote repository URL.





In Terminal, add the URL for the remote repository where your local repository will be pushed.

git remote add origin remote repository URL

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git remote add origin https://github.com/shashankgrs21/delete_user.git


git remote -v
# Verifies the new remote URL


Pull origin master

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/shashankgrs21/delete_user
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
Merge made by the 'recursive' strategy.
 README.md | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

Push origin master

dalveer@Nayak:/var/www/afeather-way/sites/all/modules/delete_user$ git push origin master
Username for 'https://github.com': shashankgrs21                          
Password for 'https://shashankgrs21@github.com':
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 22.72 KiB | 0 bytes/s, done.
Total 10 (delta 2), reused 0 (delta 0)
To https://github.com/shashankgrs21/delete_user
   a9b7cb1..74908e6  master -> master

No comments:

Post a Comment