简体   繁体   中英

are there forks and pull requests on clean git?

Can I use repository forking and pull requests when using only git (no github, gitlab, etc)? I did not find a guide where there are pull requests without using a git (CLI only). If these are where can I find guides and documentation?

In theory and practice you can still use git as your distributed version control system( DVCS ) without having the need for any repository hosting service like GitHub/GitLab/BitBucket, though using such services is a great idea and indeed recommended.

If by fork you mean just getting a copy of another git repository, then yes you can achieve that by using the clone command,

git clone <path-to-another-git-repository>

Once you have the clone, you can work on it as usual. You can verify that your remote is pointing to the original repo with git remote -v If you want to pull in updates to any of your repository, just make sure that particular repository's remote is properly set. Once the remote is properly set, you could pull in changes with git pull <remote> <branch-name> . Similarly you can push in your changes to. However if the remote repo to which you are pushing your changes has the same branch checked-out then git will throw error citing possibility of the working tree becoming inconsistent.

If the git repo is sitting on same system, <path-to-another-git-repository> will be just file system specific path. Git supports several protocols, one of which is the local protocol .

Pull-requests:

  1. Make a pull request

https://git-scm.com/docs/git-request-pull

git request-pull known-branch  origin  new-branch

It will print a lot of stuff, what you really need is

  • The URL https://domain/mygit.git
  • The branch new-branch

You send them (email) to the person who should pull, and ask them to pull that branch.


  1. Accept a pull request

in your local git do

git pull  https://domain/mygit.git  new-branch

Then you can compare this new branch to your data. You can merge or rebase it whatever you want.


It is even possible to accept a pull request from an unrelated repository.

Say someone copied a file from your project, into their own independent git. Now they made changes, and send a pull request.

git pull --depth=1 https://domain/mygit.git  new-branch

"depth" how ever many commits you need.

This is still a new branch, even so it does not actually "connect" to any of your branches.

You can cherry pick from this branch, or rebase it (using rebase with all 3 arguments) onto your branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM