Linux kernel's project is using git as its version control system. Some of the following commands may be useful :
Create a Git repository
# Run it in your development directoryThis folder will then contain a .git directory containing the complete history of the repository and .git/config will store the local configuration for it.
git init
Add files to the repository
# Replace . by the file name if you're not planning to add all filesThe marked files have been added to the staging area. It means that they will be part of the next commit. All of your modified files need to be staged (added) so that they will be included in the next commit.
git add .
Check repository status
git statusYou will see which files have been modified, which ones are staged and which are not, conflicts, etc...
Commit files to the repository
git commit -m "Commit message"
Trace back your modifications
git logYou will see the list of your commits and your activity in your working tree.
Move / Rename a file
git mv <orignial file path> <new file path>
Remove a file from repository
git rm <file name>Note : you can also simply delete the file manually. In this case, you have to add the '-a' option to the commit command to take the deletion into account.
Remove a file from staging area
git reset <file name>
Working with Remote Repositories
Ok, now we got the basics, how do we synchronize our work with others ? In the example above, we started from scratch, and our repository is local. What if somebody would like to copy it ?Clone a remote repository
Imagine that we created a repo in a folder named "original_repo". Let's move back and create a new folder :cd ..Once we're here, we will clone the "original_repo" into "clone_repo" :
mkdir clone_repo
cd clone_repo
git clone ../original_repo.git .Note : A git repository address always end with a ".git" extension.
Note 2 : If you omit the '.' at the end of the command, git will create a directory named like the origin (here 'original_repo'), move into it and pull the files from there.
If the git repository is hosted on the web, it is almost the same :
git clone https://linux389pi@bitbucket.org/linux389pi/linux389pi.git
Push changes to a remote repository
You probably noticed that git commit does not mirror your modifications on the remote repository. Instead, it creates a local commit object (snapshot). To send your modification to the central repository, you will have to push your local repository:
git push
Pull changes from the remote repository
The opposite action of pushing is pulling. You will synchronize your repository with the central one by pulling :git pull
If you are looking for more information about git, check this link :
Git - Book
Git in practice
If you are also willing to experiment git with a very cool tutorial, here is the link :
Git in practice
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.