Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»How to Clone Git Repositoty and Add New Files

    How to Clone Git Repositoty and Add New Files

    RahulBy RahulAugust 22, 20152 Mins ReadUpdated:November 17, 2017

    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 the 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 "[email protected]"
    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 commits 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 to the remote repository.

    git push origin master
    
    Username for 'https://github.com': my_git_user_name
    Password for 'https://[email protected]':
    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
    
    
    git git add git commit
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install or Update OpenSSH Server on Debian Linux
    Next Article How to Create Branch in Git Repository

    Related Posts

    How to Create Empty Branch in Git Repository

    1 Min Read

    How to Install Latest Git on Ubuntu 22.04

    Updated:May 31, 20222 Mins Read

    How To Install Git on Fedora Linux

    Updated:May 31, 20222 Mins Read

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.