I have installed GitHub Client to my system.
I have easy to commit my changes to the repository. But my colleague tried to take my update, he is not able to took the app from repository.
We are having GitHub private repository.
Kindly let me know to solve this issue.
The similar question has been asked before follow this link hope it may help you.
Basic flow is like this.
# clone the repository (from github, for example)
git clone git#github.com:username/reponame.git
cd reponame
# edit some files
# add them to the index
git add file1.txt
git add file2.gif
# review your changes
git status
# commit the changes
git commit -m "Decription of my change"
# push them back to the remote repository
git push origin master
If your colleague is supposed to:
access your private repo
be able to contribute back (git push) directly to that private repo
you should add him/her to the list of collaborators for this project: see "GitHub help page".
Note that Users can always collaborate on private repositories, even on the free plan.
I.e. if a user has a GitHub account (even a free one), he/she can be added to a private repository.
Related
I'm new to git and GitHub so sorry if this question is simplistic. A vendor has developed the WordPress theme for our website and has created GitHub repo of the theme. We want to clone the theme to our an organization which has been set up on our enterprise GitHub account. However, I'm not quite understanding the process for the process for doing this. When I search cloning it's the answer always is discusses cloning from a GitHub repo to a local repo, whereas we want to clone from a private GitHub repo to a repo in the setup in our organization.
Transferring a repo would mean you are the owner of the original repo.
If you are not the owner of that vendor theme repository, you do have to clone it locally, and then:
change its remote to refer to a new empty repo created in your GitHub organisation
push everything
That is:
git clone --mirror git#github.com:user/repo.git
cd repo.git
git remote set-url origin git#yourGitHUb.com:org/empty-repo.git
git push --mirror
In this case,I guess you need to transfer the ownership of the repo. You can refer this
https://help.github.com/articles/transferring-a-repository/
Hope this helps!
EDIT 1:If you just need a copy of the original repo (Note: further changes in original repo will not reflect in yours unless you do a pull after forking it)
https://help.github.com/articles/fork-a-repo/
First I have created one project in Eclipse and committed to my GitHub using below commands:git init
git add .
git commit -m "first commit"
git remote add origin URI of my repo
git push -u origin master
Then I modified one file in Eclipse and committed to GitHub from Eclipse through creating remote and giving the remote URI of the repo.
I added my team member through add collaborator.
Then he downloaded my project and made a change in a file in Eclipse.
Now, how can he push that modified file to my GitHub repository from within Eclipse?
We have done one thing. He created a remote and gave the URI of my repo. But still we are unable to commit that file.
You need to add your colleague as a collaborator. This can be done in the desired GitHub repo via Settings > Collaborators (you need to type in your password again). Afterwards they have those permissions.
UPDATE
Sorry and good morning ;)
I overlooked that you already added your partner as a collaborator. Another possible reason for your situation could be in the Temporary interaction limits where you can, amongst others, limit the interaction with your repo to prior contributors.
If that doesn't help. Please add some more informations about your colleague's git logs.
UPDATE 2
#Rahul K regarding your comment (which you better add to your question, for faster recognition), your colleague first needs to integrate the remote changes via git pull origin master in order to be able to push his or her changes afterwards. But be aware that he or she might need to migrate any conflicts to files both of you applied changes to.
Best regards, David
I have resolved the issue by cloning the repo in my local folder, adding the project to eclipse and changing the file committed.
Before that you have to add that person as a collaborator. So that he/she can clone your repo using the command below:
git clone "Path to the repository"
This is an old question but I'll like to say this to help others that might still be facing this same issue.
I also faced this issue with a friend. I already made him a collaborator but he couldn't push. What we did to solve it was to clone the repo using the ssh url instead. Then we set up authentication in git with ssh. And we were able push successfully.
If you already cloned the repo with the usual HTTPS url, you can change the remote origin url using the git remote set-url origin <url> command but url here will be the ssh url.
I just got a new job recently, and all repos of their projects are on BitBucket.
I used to use a lot GitHub, so I was wondering if there is a way to sync contribution between the two.
I have already tried https://github.com/jrm2k6/contwidgetor. It seems like a way to do it but didn't work for me somehow, and there is only limited support of it.
You can use Contributions Importer for GitHub
It copies all commits from source git repositories to a mock git repository. Each copied commit will report the same commit date, but the original code is not copied, neither the commit message.
The mock code is generated using the same language of the original source repository.
For example, I have a mock repository on my profile that reports all the activities of all my private repositories.
You can at least manually mirror any Git BitBucket repo from BitBucket to GitHub:
git clone --mirror http://user#bitbucket/user/repo.git
git remote add github http://user#github.com/user/repo.git
git push --mirror github
(Create an empty repo on GitHub side first)
Then, on demand, you can go into your local clone, do a fetch, and then a git push --mirror github again to sync new commits.
I was in the same situations, so I just whipped a node script together. I think it's more simple (implementation wise) than the solution posted by mir88.
The program then makes a shadow repository on GitHub. Each Bitbucket repository is represented by a file, and each Bitbucket commit is reflected by the Bitbucket commit hash.
The Bitbucket hashes are added backwards in time so the match the point in time when the original commit was made on Bitbucket.
Should be easy to change to your exact needs.
Feel free to check it out: Bitbucket 2 GitHub Activity Sync.
I'm fairly new to GitHub, so I hope you can help out. There's a branch on a repo that I want to push changes to, but I'm not added as a collaborator on it. What steps do I need to take to push changes to that branch?
I have done some research and found that I may need to fork the repo, make changes locally then create a pull request, but I'm still a bit confused about it. I would appreciate any help.
You can't simply push to the branch which you dont have the write access. You can simply fork the repo by clicking it fork button. Then clone the repo locally by using the command below
git clone https://github.com/your-username/project.git
Then you need to checkout to the branch which you need to make the change just use:
git checkout branch_name
Then make the necessary changes. Now you will have to commit the changes:
git add --all .
git commit -m "changes description"
git push
Now visit the repository in your profile. You can see a notification to open a new pull request.
Please see this for more info: https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/
Is there a way to fork from a specific branch on GitHub? … For example, moodle has many branches (1.9, 2.0 … and so on). Can a clone be performed of just branch 1.9 and not the master branch always? Is it possible to clone a specific branch onto my PC?
I don’t know a native way yet, but you can do it following this recipe:
Fork the repository in question (called ‘upstream’) on the GitHub website to your workspace there.
Run the GitHub desktop application and clone the repository onto your PC.
Use the GitHub desktop application to open a shell in the repository. (The git commands are not available from the default PowerShell unless you configure that manually.)
Set the source repository as upstream:
git remote add upstream https://github.com/{user}/{source-repo}.git
Fetch the full upstream repository. (Right now, you only have a copy of its master branch.)
git fetch upstream
Make your file system copy the branch you want and give it any name:
git checkout upstream/{branch-in-question}
git checkout -b temporary
Publish your repo using the GitHub desktop application.
On the GitHub website, open your repository and click ‘settings’.
Change the “Default branch” to ‘temporary’. (Just change the drop-down menu, you don’t need to click the “Rename” button.)
Go back to your repository, go to the ‘branches’ tab, now you can delete the “master” branch.
Delete the master branch on your shell and make a new master branch:
git branch -d master
git branch master
git checkout master
git -d temporary
Once more, publish your repo using the GitHub desktop application.
On the GitHub website, open your repository and click ‘settings’.
Change the “Default branch” back to the (new) ‘master’ branch.
Go back to your repository, go to the ‘branches’ tab, now you can delete the “temporary” branch.
This should be what you were looking for. Perhaps GitHub will provide a more convenient way to do this in future (e.g., clicking “Fork” from a project’s branch results in exactly this behaviour).
Cloning means that you create a copy of the whole repository in your account including all branches and tags. However you are free to switch and track branches however you like.
No command line needed. Just create a new branch in your forked repository in GitHub. GitHub will ask you if you want to clone/mirror this new branch from the upstream repository. You can give any name to the new branch.
Yes, you can clone the single branch. For example, you have a branch named release1.0. If you would like to clone this branch into your pc then use the following line of code:
$ git clone git#bitbucket.org:git_username/git_repository_example -b release1.0 --single-branch
For those who don't like working with command-line. Here is a simple guide using the desktop client for GitHub:
Click the fork button of the repo on GitHub.com:
Make sure you have the desktop client installed
Click this button:
Clone the repo
In the desktop client, select the desired branch
Select the branch you'd like to work on and you're done
I'm posting here the method I've used.
Like the OP I wanted to only copy/fork one branch. But couldn't find an easy way.
in your repo create a new branch. It doesn't need to have the same name as the branch you want to fork
once created, verify that it is the selected branch, and click "Compare"
reverse the order of comparison (I have a userscript for that, see my profile if it's something you want to test).
the "base" repository must be yours, with the branch you've created
the "head" repository is the original, and the branch is the branch you want to fork
hit "create pull request" and continue until the PR is applied
That's it. You have the branch forked.
I'm using bitbucket but I'm sure this would work for GitHub as well.
Create a new repository
Checkout the branch using GitExtensions
Click Push to open the Push dialog
Set the destination URL to the new repository
Set the destination branch to "master"
Push
Your new repository will have the full history of the one branch only (not all branches like forking will have).
A fast, alternative approach is to create your own new repo.
Go to https://github.com/new and make a new repo. Do not initialize with README.
Scroll down to get your git remote
Then:
git remote rm origin
git config master.remote origin
git config master.merge refs/heads/master
// Run code from above image
git push --set-upstream origin yourbranchname
You will have a new repo with the original repo's code and a branch that can be made into a pull request.
SOLUTION:
For remote repository on GitHub and local repository
After fork all branches to your GitHub repository, you can delete Redundant branches in your GitHub repository.
And then you can only clone the branches you need to local.
Step One
Step Two
Only For local repository
git clone -b <branch name> --single-branch <repository>
If you want to further save your disk space, you can clone remote repository without history:
git clone -b <branch name> --depth 1 <repository>
notice: --depth implies --single-branch unless --no-single-branch is given.
https://git-scm.com/docs/git-clone
Switch to the branch you need in source repo
Click "Fork". You'll get forked master and the branch you're in.
I don't know how it works with more branches, but for my needs worked pretty well.