Difference between revisions of "GIT short instructions"
From hpcwiki
(→Working with git) |
(→Working with git) |
||
Line 46: | Line 46: | ||
#: <code>cd workspace/myProject</code> | #: <code>cd workspace/myProject</code> | ||
# Obtaining the last committed changes | # Obtaining the last committed changes | ||
− | #: <code>git pull</code> | + | #: <code>git pull ssh://username@server-host/var/repo/myProject.git</code> |
# Submitting the local changes to the co-workers | # Submitting the local changes to the co-workers | ||
## Adding files and modification | ## Adding files and modification | ||
Line 53: | Line 53: | ||
##: <code>git commit -m "Message that describe the changes in the project"</code> | ##: <code>git commit -m "Message that describe the changes in the project"</code> | ||
## Pushing the changes in the external repository | ## Pushing the changes in the external repository | ||
− | ##: <code>git push | + | ##: <code>git push </code> |
== Branching Git Repository == | == Branching Git Repository == |
Latest revision as of 15:42, 17 February 2015
Contents |
[edit] Repository creation
- Create a directory for the information to be under version control
-
mkdir myProject
-
- Open the directory
-
cd myProject
-
- Initiate an empty repository
-
git init
-
- Add current files to the repository
-
git add .
-
- Commit the changes to the repository
-
git commit -m "message with a brief description of the changes"
-
[edit] Remote repository creation
- Login in the external server via ssh
-
ssh username@server-host
-
- Go to repository directory
-
cd /var/repo
-
- Create a directory for the information to be under version control
-
mkdir myProject.git
-
- Open the directory
-
cd myProject.git
-
- Initiate an empty shared bare repository
-
git --bare init --share=group
-
[edit] Mirroring to a remote server
- Add the external repository
-
git remote add origin ssh://username@server-host/var/repo/myProject.git
-
- Push the local files to the repository
-
git push origin master
-
[edit] mirroring to the web server
- Create a mirror of a bare repository
-
git clone --mirror ssh://username@server-host/var/repo/MyProject.git
-
- Update the local content
-
git fetch -q --all
-
[edit] Clone a git project
- Go to the directory where the project will reside, in this example workspace
-
cd workspace
-
- Clone the external project
-
git clone ssh://username@server-host/var/repo/myProject.git myProject
-
[edit] Working with git
- Change the directory to the project directory, in this case inside workspace directory
-
cd workspace/myProject
-
- Obtaining the last committed changes
-
git pull ssh://username@server-host/var/repo/myProject.git
-
- Submitting the local changes to the co-workers
- Adding files and modification
-
git add .
-
- Committing to the local version
-
git commit -m "Message that describe the changes in the project"
-
- Pushing the changes in the external repository
-
git push
-
- Create a new branch
-
$ git branch MyBranch
- where MyBranch is the branch to create
-
- Switch to an existing branch, you run the git checkout command. Let’s switch to the new MyBrnach branch:
-
$ git checkout MyBranch
-
- A short instruction to create a branch and change to it as a working copy is:
-
$ git checkout -b MyBranch
-
- To switch between branches: (in this case to the master or trunk)
-
$ git checkout master
-
- To merge a branche with the master:
-
$ git checkout master
-
$ git merge MyBranche
-
- Now you are ready to delete the merged branche:
-
$ git branch -d MyBranche
-
- To push a branche in the repository
-
$ git push -u origin MyBranche
-
- To checkout a branch from the repository
-
$ git checkout -b MyBranche origin/MyBranche
-
[edit] Branching Git Repository
The next instructions were taken from the GIT-SCM Branching