Hike News
Hike News

Git Basic in Practice (II)

Working with remotes

Note: Remote repositories can be on your local machine.It is entirely possible that you can be working with a “remote” repository that is, in fact, on the same host you are. The word “remote” does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere. Working with such a remote repository would still involve all the standard pushing, pulling and fetching operations as with any other remote.

Showing your remotes

To see which remote servers you have configured, you can run:

1
git remote

You can also specify -v, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote.

Making some changes

Git is used to create and store some snapshots attached to your project and to compare these files with the following versions. Here are some important commands to accomplish this task.

From changes in files to snapshot

To add some modified files into cache, you can run:

1
git add <file name>

It is common to add all files in a folder. So you can run this command to save your time:

1
git add .

After adding these files, you can use the command git status -s to check the status of snapshots in cache. If you want to get the details, you can run:

1
git status

Also, you can check more detailed information by git diff.
Note: git status will tell you the modifications put into cache, and git diff will tell you what these changes are row by row.

From snapshot to repository

Before you send the git to the remote repository, you must put the changes in snapshots (created by git add) into local repository. So you must run:

1
git commit -m'this is some description about the changes'

After this operation, you can usegit status and you can find that nothing to commit (working directory clean).
Since you have finished git commit, you can upload your repository to the remote ones like github. Don’t forget to set your name and password just as the former post says.