Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Commit Changes to git

    • 0
    • 3
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 246
    Comment on it

    Commit Changes to git : As we know git is a popular version control system for projects.Here I will guide you how to do changes in repository files and save those changes in repository. When we save or commit our changes then the git creates a new version of the file or project.

    git add : The git add command will add the files into the staging area. All the files which are changed from the last commit, we first put those files in staging area. If all set and all changes are verified then we can commit the changes to repository. Git add doesn't effect the repository until we commit our changes. We can also run the git status command to check the status of the current repository. It will list all the files which are under staging are and need to be tracked.

    $ git add test.txt
    

    The above command will put the test.txt file to the staging area.

    $ git add <directory>
    

    The above command will add the particular folder to the staging area to commit.

    $ git add .
    

    The above command will add all files recursively to the staging area.

    Every time you made changes in the file or you added new file or folder, you have to put that file or folder to the staging area.And when you feel everything is fine then you can run the git commit command.

    git commit : The git commit records all changes into the repository. After running this command a snapshot of the changed files are saved into repository. The git commit command will create a new version of the project.The snapshots are committed to local repository and not effect the other local or remote repositories.

    $ git commit
    

    The above command will commit the staged snapshot.This will launch the default text editor that prompt you for commit message. After entering the commit message save the file and close it.

    If you don't want to mess around with text editor for commit messages, then you can use the following command.

    $ git commit -m Commit message.
    

    The above command give you freedom to write your commit message with the commit command.

    Git does not force you to interact with the central repository until you are ready.So the git work flow is like first you create a repository, then add files into this repository then those files put into staged area and finally committed in the repository.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: