why do you need to put branch name in git pull remote <branch> if the updated branch is where you are? - git-pull

when I do a git "pull origin master" from a branch the branch is updated NOT the master. In order to update the master I need to do a "git checkout master" and then call "git pull origin master". Why is "master" needed in the command if the updates take place to the current branch and not necessarily the master.

Because it is specifying the branch on the remote end that you want to merge with your current branch. So git pull origin master literally means: consult the repository at the URL defined by the origin remote, check it's master branch, download whatever I need to have a copy of that branch in my repo (which will be saved as a branch called origin/master), and merge that branch into whatever branch I happen to be on at the moment.

Related

Committing specific changes on gh-pages branch via a GitHub action that triggers on pushes to master

I have two branches in a repository which contains an R package:
the 'master' branch,
and a 'gh-pages' branch, from where the documentation website for the package is hosted.
Whenever there is a commit to master changing any of the R files present in the R/ folder, (i.e. tree/master/R/*.R) I would like to push those changes to the gh-pages branch via GitHub Actions. (these R files are used to generate the man files which in turn create the documentation) I wouldn't like to push changes other than those involving a change in R/ directory, since they are irrelevant for the purpose of generating the documentation.
How can we update such changes on a gh-pages branch (or any other branch) via a GitHub Action which triggers on pushes to the master branch, considering only commits for the R files within the R/ directory? Could someone show an example of a .yaml file introducing such a workflow?
Help will be appreciated!
There are two actions for gh-pages that might help you:
github.com/peaceiris/actions-gh-pages
github.com/marketplace/actions/deploy-to-github-pages
The second gives a .yaml example that correspond to what you want to do.
Moreover, you can specify in your workflow.yaml file which directory to watch to trigger your workflow.
There is an example in this stackoverflow question: Github Actions - How do you trigger a push when a specific directory in a branch gets an update?
(This example is with a push but you can use with other options as well)

Does the master branch on my forked repo automatically update the master on the original repo in github

I am very new to github which I am using with rstudio. I have forked a repo, made branches and merged them back in to the master branch for the forked repo. How then do I merge the changes from the forked master branch back in to the original repo?
I though I had to issue a pull request from the fork but all I am presented with in the forked repo is that the master branch is the default branch. The other branches all have buttons associated with them that allow me to create a new pull request but not the master.
Am I thinking about this the wrong way? How do I get my master branch integrated in to the original repo?
The workflow you're looking for goes something like this:
Make changes on the local copy of your forked repo, on a feature branch.
Push that feature branch to the forked remote on Github.
Visit the forked repo on Github; Github will prompt you to open a pull request from your forked feature branch to the upstream repo.
Open the PR, get it merged.
Update your fork with the changes from upstream (these commands run from the the root directory of your local fork):
$ git fetch upstream
$ git merge upstream/master
$ git push
By pushing your changes to your forked master, it's diverging history from the upstream. Most of the time (such as in OSS contribution), the upstream is the 'source of truth' and has the final say about what goes on both of the master branches.

arc diff --update always create new review

I download code from Gitlab, then create a new branch, update some files and create a review. Then I add a file, execute arc diff --allow-untracked, it reports Usage Exception: There are several revisions which match the working copy:. I execute arc diff --allow-untracked --update D75 to update the existing review, but it creates a new review.
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
SKIP STAGING No staging area is configured for this repository.
Updating commit message...
Created a new Differential revision:
Revision URI: http://codereview.domain.com/D76
I try many times but it always creates a new revision. How to use arc diff --update?
You shouldn't need --update but you do need to specify the base of your change, so to update the revision associated with the current HEAD, try the following:
arc diffHEAD^
If you've got two commits then you need to use HEAD^^.
To update everything on the current branch:
arc diffparent-branch
So assuming your current branch was branched from master:
arc diffmaster
The arcanist documentation covers this topic in detail, so for a more complete understanding of how arc diff decides which commits to submit, read Arcanist User Guide: Commit Ranges.

Is it possible using git to create a branch for existing files?

This might be a simple question but I have project on git and I am tasked with revamping it. So I started writing a bundle in Symfony which I got at a good state. Is there a way now to make this a branch of git? I probably should have created a branch, deleted everything and then started my project in the empty branch right? So can I do the same now, create a branch, delete all files and just copy my files there? I think as long as they stay in the src folder it should be ok, right?
git checkout -b new_branch_name
A new branch will be created and all your files will be moved there.
This assumes that you have already created a clone to your remote repository and the new_branch_name will be used when pushing.
After this new files can be copied and deleted from where this command was run. Then you must run:
git add *
This will add all files from this folder and subfolder that are to be tracked. Then you must commit them to be maintained in history:
git commit -a -m "Some message saying why you committed them"
Then you can push them to your remote repository:
git push Nameofremote Nameofbranch
In the case above it would be the following assuming you didn't rename remote or switch head:
git push origin new_branch_name
Used This to help me along.

How to view GitHub Contributors Graph for branches other than master?

At https://github.com/yourusername/yourreponame/graphs you can find some nice graphs showing commits over time. However the information is only for the master branch.
How do I see the same information for a branch other than master, or see a graphs taking account commits across all branches?
If this is not possible, how can I at least see how many line of code have been committed under a particular branch via the GitHub web GUI?
Is any of this possible?
I just stumble on this as well. You can actually see the graphs for other branches than the Master branch.
On Github in your repo - choose settings.
In settings - change your default branch to whatever branch you would like to see the graphs for.
The help of Github: Viewing contributions :
Whenever you commit to a project's default branch (or the gh-pages branch), open an issue, or propose a Pull Request, we count that as a contribution.
So:
default branch
gh-pages branch
open an issue
pull request
only these will be counted.
As #Mikael 's answer, you can change the default branch in repo's settings.
Another help of Github: Which contributions are counted?
For commit:
Your commit contributions are only counted when they are created on or merged into the default branch or gh-pages branch of a non-fork repository.
I also want github to count all the commits, not specified branch :(
From what I can see, those graphs are for master only: I only committed on the branch gitlist recently, and my commit activity only shows those for master.
Unless you rebase your branch on top of a new repo you would create specifically for that kind of inspection, said branch activity won't be visible until it is merged back in master.

Resources