How to make pull request? - github

I am new in git and in nodejs. My question is I build a project and uploaded it on github in main branch. But members are asking to to give pull request. How can I make a pull request please tell me full procedure with commands if possible thankyou.
I uploaded on git like this
Git init
Git add .
Git commit -m"initial commit"
Git git add origin main githublink(ssh)
Git push -u origin main
After this my project is uploaded successfully
Now how can I make a pull request

first you need to checkout from the main branch by git checkout
then you develop and code in that branch
next you commit and push that branch on github repo
git commit -m"initial commit"
git add origin <your_branch> githublink(ssh)
git push -u origin <your_branch>
finally you access the github page and your new branch. create a pull request into the main branch. then share that pr to your colleagues.
for example the last step:

Related

How do I sync tags to a forked github repo?

I forked a repository on github and use the "fetch and merge" button on the web page to sync the latest code to my fork. I noticed that the code gets updated but new tags from the master repro don't end up in my fork. How do I make that happen?
You would need, in command-line, to fetch tags
git fetch --tags upstream
Assuming upstream is the remote name referencing the original repository URL.
Then push tags to your fork
git push --tags
If you want to push only the tags from the branch you are pushing:
git config --global push.followTags true
That way, a simple git push is enough.
For the first one, this also works
git fetch --tags <remote-url>

Files not appearing on github

I am new to web development and have just created my first project. I created a new repository on github and then did the following on git bash:
Moved to the working directory for my project
Initialized the git repository using git init
Added my files using git add .
Committed the files using git commit -m 'my message'
Added the github URL under code. on github by using git remote add origin 'my_url_name'
Pushed the code to github using git push -u origin master (also entered my passphrase correctly as I am using SSH)
Git Bash confirmed the upload and then nothing appeared on my repository on github
Note. I did get a message at the top of the repository saying "master had recent pushes x minutes ago: with a button that says "Compare & pull request" though the page just shows a message "There isn't anything to compare."
Am I missing a step?
The branch selected in your git is master. But in GitHub is main. To display your codes in GitHub, you need to change the Git branch to main.
First delete previous repository in Github and create a new , then act according to the following codes in the git :
git branch main
git checkout main
git merge master
git branch -M main
git remote set-url origin https://github.com/masoud8911/example.git
git push -u origin main
It could be that your local branch name is main not master. You can check this locally with:
git branch.
try instead:
git push -u origin main
Make sure you are selecting the correct branch on github. At the top of the repository, on the same line as "Go to file" "Add file" and "Code" on the far left is a button to select the branch. Make sure the branch is the same as the branch used as origin when the push was declared on Git Bash.

Is there any way to clone a specific brach in git desktop?

I tried but its cloning whole repository. I wanted to clone only specific branch in that repository
Thanks in advance
You only can clone a whole repository except a branch, the code is:
git clone -b mybranch --single-branch git://sub.domain.com/repo.git
If you already have the repository cloned, you can refresh the branch you want, if you have forked the project you can refresh the specific branch you want. the code is:
git checkout 'branch if you want to change to refresh it'
git pull <URL of REPOSITORY> 'branch that you want to refresh it'
git commit -m "message"
git push upstream 'branch that you want to refresh it'

Sync my Pull request with someone else commit some changes - Github

I sent a PR and someone else made some changes so it has 3 more commits and now I need to sync that PR with my local to continue working on some changes. How could I do to sync my local with the PR. Thanks
A pull request is basically just a designated branch on your fork of the repository. Update that branch (by rebasing its commits on top of those new commits) and the pull request will automatically update to show these changes.
First, you need access to the additional commits in your own fork of the project. To do so, you can add the upstream repository as an additional remote and fetch the commits from there:
git remote add <new-remote-name> <upstream-url.git>
git fetch <new-remote-name> <upstream-branch>
Then you can rebase your changes on top of the upstream changes:
git checkout <your-pr-branch>
git rebase <new-remote-name>/<upstream-branch>
git push <origin> <your-pr-branch>
You need to rebase your branch to reflect all the merged work of others in your PR. Here is how you can do this:
Let's say upstream is the name of the remote repository which you have forked, and origin is the name of your forked repository.
git pull --rebase upstream master
git push origin master
There can be merge conflicts sometime during rebasing. In that case, check the files in which conflicts are there using:
git status
The name of the files which are in red color are the files having conflicts. Resolve the conflict manually. After resolving, add the files using:
git add <filename> or //for each conflicted file
git add --all //to add all files at once
Once again check the status using the git status command. If all the files are shown in green that means they are resolved and you can now continue your rebase. Run the below command for continuing your rebase:
git rebase --continue
Once done, simply push the changes to your forked repo using:
git push -f origin master
Note: In case, you have not set the remote url of your upstream and origin, add them using following commands:
git remote add upstream <upstream-url>
git remote add origin <origin-url>

I've fork a repo in github. How could I fetch all changes from the original repo?

In this case, I've fork grocery-CRUD repo from github.
I make some changes, and submit a pull request.
The author accept it, and do some other modification.
How could I fetch the newest modification to my grocery-CRUD repo?
Thanks
You add his repo as a remote (git remote add <his repo> <repo spec>).
Then, you pull changes from his repo (git pull <his repo>)
Then, you push the changes to your repo (git push origin)
git pull git://github.com/scoumbourdis/grocery-crud.git
This will fetch the changes and merge them with your current branch in your local repository.
If you want to get it on your remote you need to push
git push origin