How to Clone from GIT and Commit the Code to GIT


How to Clone from GIT and commit the code to GIT?

What is GIT?

Distributed revision control system with an emphasis on being fast

Every GIT working directory is a full-fledged repository
-> Includes complete history
-> Full revision tracking capabilities

Not dependent on network access and or a central server

How it works:

Master Branch
-> Coding never occurs in the master branch
Branches
-> Development is done in branches

Typical Work Flow:

  • Clone Repository To Computer
  • Create a local branch of the master branch
  • Switch to that branch (local branch )
  • Make changes to files in local branch
  • Commit changes to local branch
  • Switch back to master
  • Perform a pull operation
  • Accept latest changes
  • Merge local branch to local master
  • If successful, push changes back to remote master

Installing GIT:

Download GIT for windows from below URL and install
https://help.github.com/articles/set-up-git#platform-windows

Get the code from GIT central repository:

Use the following command in your local repository to get the code form remote repository.

git clone  (Clone the remote repository your local repository)

Commit your changes to the remote repository:

Once you created the local repository, there will be a default branch called “master”. Below is the command to view the local branches.

git branch (Shows all the local branches)

To create a new local branch.

git branch <branch name>  (It will create a new local branch with the given name)

Now make the changes to your code in new local branch code and commit those changes.

Commands to commit into your local branch::

git add or git add (add the changed file(s) to staging)

git commit -m ‘your commit message’ (commit all the changed files in staging)

After committing your changes in the local branch.  Switch to master branch from the local branch.

git checkout master (switch to master branch)

Sync your local master repository with the remote master repository.

git pull (Fetch the changes from the remote repository and merge them into your current branch)

Merge the new local branch changes to your local master branch.

git merge (merge branch into the current branch)

If there are no merge conflicts. Then push your local master changes to remote repository.

git push (Push the changes to master branch in remote repository)

That’s it you are done now your local changes moved to the remote repository.

 

Comments 1

Your email address will not be published. Required fields are marked *

log in

Become a part of our community!

reset password

Back to
log in