How to Clone Git Repositoty and Add New Files

Today our team is starting a new series of articles for GIT Management. In the first article you will learn How to Clone Git repository from remote server and add files and push the files to Git server.
We are assuming that you already have installed Git client on your system. And you also have a working git repository url. If you don’t have git repository url create new on Github.
  • Clone Repository

    – First make a clone of remote repository on your local system as following command.
    $ git clone https://github.com/tecadmin/firstrepo.git   Cloning into 'firstrepo'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. Checking connectivity... done. 
    Change the repository url.
  • Add Your Identity

    – Now set your identity for the new repository cloned on your local system. Navigate to local directory and use following commands
    $ cd firstrepo/ $ git config --local user.email "youremail@example.com" $ git config --local user.name "Your Name Here" 
  • Create Project Files

    – Now create some files in newly cloned directory or copy them from your existing projects to this.
    $ touch file1.txt $ cp -r ~/oldProject/* . 
  • Add Files to Git

    – Now add newly created or copied files to your git repository.
    Adding Single File:-
    $ git add file1.txt 
    Add All Files:-
    $ git add -A 
  • Commit Your Changes

    – After successfully adding new files to your local repository. Now commit your changes. This commit your files in local repository only.
    Commit Single File
    $ git commit file1.txt -m "New File Commit" 
    Commit All Files
    $ git commit -a -m "All Files Commit" 
  • Push Your Changes

    – Now push your changes to remote git repository using following command. This will upload your files on remote repository.
    $ git push origin master  Username for 'https://github.com': my_git_user_name Password for 'https://my_git_user_name@github.com': Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 278 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/tecadmin/firstrepo.git    2913fe6..cc8ebe7  master -> master  

Thanks for Visit Here

Comments