美文网首页
How to use git deploy projects t

How to use git deploy projects t

作者: ccphantom | 来源:发表于2017-07-28 05:01 被阅读0次

    1. Generate project Git repository

    1.1 Use command line

    git init
    

    1.2 use pycharm

    ps. with pycharm, you only need to enable VCS function, it will create git repository automatically.


    Enable VCS

    2. Commit the change to the git repository.

    2.1 Use command line to commit file

    Use git status to see untracked files

    git status
    

    Tracking new files

    git add <file_name>
    

    2.2 Use Pycharm to commit file

    Right click "Default" line, and then click commit to commit files.

    Commit files

    3. Export an existing repository into a new bare repository.

    In order to initially set up any Git server, you have to export an existing repository into a new bare repository – a repository that doesn’t contain a working directory. This is generally straightforward to do. In order to clone your repository to create a new bare repository, you run the clone command with the --bare option. By convention, bare repository directories end in .git, like so:

    ~$ git clone --bare my_project my_project.git
    >>> Cloning into bare repository 'my_project.git'...
    >>> done.
    

    4. Putting the Bare Repository on a Server

    4.1 Solution 1. Simply use USB to copy the git repository to the server.

    4.2 Use SSH to access to server

    Let’s say you’ve set up a server called git.example.com that you have SSH access to, and you want to store all your Git repositories under the /srv/git directory. Assuming that /srv/git exists on that server, you can set up your new repository by copying your bare repository over:

    ~$ scp -r my_project.git user@git.example.com:/srv/git
    

    At this point, other users who have SSH access to the same server which has read-access to the /srv/git directory can clone your repository by running

    $ git clone user@git.example.com:/srv/git/my_project.git
    

    you can also clone project to the local repository. Let's say, you have git repository "my_project.git" in local disk, and you want to clone it into another directory.
    Into the folder you want to put the project, such as you want to put the project under /home/reachnett.

    $ cd /home/reachnett
    
    /home/reachnett$ git clone file:///path/to/my_project.git/
    

    If a user SSHs into a server and has write access to the /srv/git/my_project.git directory, they will also automatically have push access.

    Git will automatically add group writes permissions to a repository properly if you run the git init command with the --shared option.

    $ ssh user@git.example.com
    $ cd /srv/git/my_project.git
    $ git init --bare --shared
    

    5. Tracking Remote Branches

    5.1 Use Command line

    When you clone a repository, it generally automatically creates a master branch that tracks origin/master. However, you can set up other tracking branches if you wish – ones that track branches on other remotes, or don’t track the master branch. The simple case is the example you just saw, running git checkout -b [branch] [remotename]/[branch]. This is a common enough operation that git provides the --track shorthand:

    $ git checkout --track origin/serverfix
    

    Branch serverfix set up to track remote branch serverfix from origin.
    Switched to a new branch 'serverfix'

    If you already have a local branch and want to set it to a remote branch you just pulled down, or want to change the upstream branch you’re tracking, you can use the -u or --set-upstream-to option to git branch to explicitly set it at any time.

    $ git branch -u origin/serverfix
    

    Branch serverfix set up to track remote branch serverfix from the origin.

    5.2 Use pycharm to tracking branches

    Click 'VCS' -> 'Git' -> 'Remotes'

    Tracking Remote Branches

    Enter 'Name' and 'URL', such as:
    Name: origin
    URL: user@ip_address:/home/reachnett/git/directmail.git

    Enter name and url

    相关文章

      网友评论

          本文标题:How to use git deploy projects t

          本文链接:https://www.haomeiwen.com/subject/auitlxtx.html