0

I want to clone a repo from my GIT to a remote server and through command line i want to create a branch and make changes and add this branch to the repo. I am accessing that remote server from my system I have used following command.

git clone <remote address of repo> <server local address>
cd <repository>
checkout <particular branch> or
checkout -b <new branch> under master
<<<<<<<made changes>>>>>>>>>>
now what ? to make these changes available to remote repository.

And I have this repository available. Now what should be the correct sequence to create branch and make changes and add this branch to the cloned repo. and create pull request.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Hima
  • 11,268
  • 3
  • 22
  • 31
  • 1
    I an not sure I got you correctly. Do you what clone a repository between two different github servers (e.g. github service and company server) ? I case you are asking about local repository and remote its the standard git flow you can read https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository – Haim Raman Jul 11 '17 at 06:36
  • @HaimRaman check out the edits. – Hima Jul 11 '17 at 08:50
  • sounds like the standard git flow. git add. git commit and git push? – Haim Raman Jul 11 '17 at 11:02
  • What if instead of Push I want to send a pull request to someone – Hima Jul 11 '17 at 11:49
  • try https://stackoverflow.com/questions/4037928/can-you-issue-pull-requests-from-the-command-line-on-github – Haim Raman Jul 11 '17 at 18:03

1 Answers1

1

git relies on external standard tools (such as ssh or existing http servers) for network communication.

The standard way to "run actions git actions on a remote server" is simply :

  • log on the remote server (e.g : using ssh)
  • run the action

For example :

  • To create a clone of the repo on your remote host :

    local$ ssh remote
    remote> cd /target/directory/
    remote> git clone ssh://local/repo  # <- or whatever url accessible from remote
    
  • To checkout a given commit :

    # interactively :
    local$ ssh remote
    remote> cd /target/directory/repo && git checkout [branch]
    
    # batch mode :
    local$ ssh remote 'cd /target/directory/repo && git checkout [branch]'
    
  • Pull changes :

    # interactively :
    local$ ssh remote
    remote> cd /target/directory/repo && git pull
    
    # batch mode :
    local$ ssh remote 'cd /target/directory/repo && git pull'
    
  • etc ...

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Yes I am accessing thoruhg ssh. I am not sure what git checkout [commit] does. "goes to the branch and commits? – Hima Jul 11 '17 at 08:51
  • 1
    @Hima Yes. To be precise: `git checkout branch/tag/commit` moves `HEAD` to the named commit (branches and tags are just labels for commits) and update files in the worktree from the tree in the commit. – phd Jul 11 '17 at 17:27