Is checkout necessary to work on branch - bitbucket

I have created a repository in Bitbucket and have added some code in the master branch. Then I created a branch dev and I intend to work on dev branch and sync it with master when required.
To work on dev, do I need to run git fetch && git checkout dev or could I simply change my local code (eg change a file or add a file) and push it on dev using following commands?
git remote add origin https://username#your.bitbucket.domain:7999/yourproject/repo.git
git push -u origin dev
I am sceptical trying this without guidance as I have faced issues where the branches are no longer in sync!

I suppose it is. When I create a branch in Bitbucket, the branch gets created there but not in my local machine. The local machine still has only master branch. the commands git fetch && git checkout dev run on local machine (in project directory) creates dev branch in local machine.
C:\...\dw-ng2-app>git fetch && git checkout dev
From ssh://bitbucket.org/ManuChadha/angularcli
* [new branch] dev -> origin/dev
Switched to a new branch 'dev'
Branch dev set up to track remote branch dev from origin.
Any changes I'll do now in local machine will be in dev and will be pushed to dev in Bitbucket.
So following commands are now applied to local dev and dev on bit bucket
C:\...\dw-ng2-app>git add --all
warning: LF will be replaced by CRLF in src/app/app.component.html.
The file will have its original line endings in your working directory.
C:\...\dw-ng2-app>git commit -m "added names"
[dev d3749c7] added names
1 file changed, 4 insertions(+)
C:\...\dw-ng2-app>git push origin dev
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 482 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote:
remote: Create pull request for dev:
remote: https://bitbucket.org/ManuChadha/angularcli/pull-requests/new?source=dev&t=1
remote:
To ssh://bitbucket.org/ManuChadha/angularcli.git
cddddca..d3749c7 dev -> dev

Related

git lfs: upload over 8G files, it stuck at 8.1G

i build gerrit server using apache2.
i has 'git push' other lfs files successfully, now i want to upload over 8.1Gb lfs files,but it stuck at 8.1Gb, no return and no error.
android#gerrit-server:~/work/project$ git push http://username#gerrit-server:8888/vendor/qcom/boot_images HEAD:refs/heads/releases-branch**
Locking support detected on remote "http://username#gerrit-server:8888/vendor/qcom/boot_images". Consider enabling it with: $ git config lfs.http://gerrit-server:8888/vendor/qcom/boot_images.git/info/lfs.locksverify true Uploading LFS objects: 98% (9892/10045), 8.1 GB | 0 B/s
Just like that, it always stuck that

Error when deploying Lektor site to Github Pages using Travis CI

I've got a Lektor site that I'm trying to deploy automatically in response to pull requests and commits, using the Travis CI trigger approach from the Lektor docs.
The Lektor configuration works fine from the command line.
The Travis build starts, and appears to build the site without problem - but when it gets to deployment, the log says the following:
Installing deploy dependencies
!!! Script support is experimental !!!
Preparing deploy
Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment/#Uploading-Files.
No local changes to save
Deploying application
Deploying to ghpages-https
Build cache: /home/travis/.cache/lektor/builds/d3a411e13041731555222b901cff4248
Target: ghpages+https://pybee/pybee.github.io?cname=pybee.org
Initialized empty Git repository in /home/travis/build/pybee/pybee.github.io/temp/.deploytemp9xhRDc/scratch/.git/
Fetching origin
fatal: repository 'https://github.com/pybee/pybee.github.io/' not found
error: Could not fetch origin
fatal: repository 'https://github.com/pybee/pybee.github.io/' not found
Done!
For a full log, see here.
I've checked the credentials in the Travis CI configuration for the repository; I'm as certain as I can be that they're correct. I've tried using the same configuration (exporting LEKTOR_DEPLOY_USERNAME and LEKTOR_DEPLOY_PASSWORD locally), and it works fine.
hammer:pybee.org rkm$ lektor deploy ghpages-https
Deploying to ghpages-https
Build cache: /Users/rkm/Library/Caches/Lektor/builds/a269cf944d4302f15f78a1dfb1602486
Target: ghpages+https://pybee/pybee.github.io?cname=pybee.org
Initialized empty Git repository in /Users/rkm/projects/beeware/pybee.org/temp/.deploytempOh4p98/scratch/.git/
Fetching origin
From https://github.com/pybee/pybee.github.io
* [new branch] master -> origin/master
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Everything up-to-date
Done!
Any suggestions on the cause of this error?
It turns out this is a bug in Lektor.
If you use the following in your <project>.lektorproject:
[servers.ghpages-https]
target = ghpages+https://pybee/pybee.github.io?cname=pybee.org
and the following in your .travis.yml:
language: python
python: 2.7
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/lektor/builds
install: "pip install git+https://github.com/singingwolfboy/lektor.git#fix-ghpages-https-deploy#egg=lektor"
script: "lektor build"
deploy:
provider: script
script: "lektor deploy ghpages-https"
on:
branch: lektor
(i.e., use the PR branch for deployment), builds will deploy as expected.

Correct way of committing changes to master branch on Github

So I am very new to Github. Please forgive me if i am asking a stupid question. So first did some reading on Github and tried to understand the philosophy about it. So i am working on my first ruby on rails app (very excited) I generated my new app and made my first commit by pushing the empty app to Github. So now i have a master branch.
Then i created a couple of models and added some fields to the tables i made. Now i would like to push this change on Github . What do i do and how? I KNOW some of you will say why would you push a change so small but i am just trying to learn GIT so then when i work on huge projects i am ready.
I basically want to commit the changes to the masters . How do i do this? I USUALLY see other peoples gits and they have messages like "fixed feature 1" 1 hour ago etc. So i want to do the same.
Please advice.
You would do that just like you pushed your earlier code - by pushing the commits you have made to remote repository.
If you are on the master branch, this will do: git push origin master (replace origin with your remote name - git remote -v will tell you all your remote names).
If you are on a feature branch, you can checkout to the master branch and then merge your feature branch - git checkout master and then git merge <feature branch>, and then push your changes again using git push origin master.
EDIT:
You can add a shortname using git remote add origin <link to remote repository>, and then use origin to push.
I am new to git as well and the answer above sounds better then mine. I have bash script on github (https://github.com/caroldomokos/columbo) which is work in progress for some time. I have the master locally as you do. When I make a change on the script I first do "git commit -a" and then "git push". I am in the "columbo" forlder on my pc. If you add a new file you first have to tell git to add it: "git add ". You can always use "git status" to see what is tracked and what has changed.To examplify I created this small sequence for you :-)
hpbcadom#LUBUNTU32:~/columbo$ echo "Git example" > example_file
hpbcadom#LUBUNTU32:~/columbo$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add ..." to include in what will be committed)
example_file
nothing added to commit but untracked files present (use "git add" to track)
hpbcadom#LUBUNTU32:~/columbo$ git commit -a
[master d799b3a] to help I hope
1 file changed, 1 insertion(+)
create mode 100644 example_file
hpbcadom#LUBUNTU32:~/columbo$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'xxxs://github.com': caroldomokos
Password for 'xxxs://caroldomokos#github.com':
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To xxxs://github.com/caroldomokos/columbo
dadf5af..d799b3a master -> master
I hope it helps :-)

Travis CI shows "Host key verification failed." when I try to clone submodule from Bitbucket

I have repositories A, B, C and D. A, B and C run on Travis CI. All repositories are located on Github except for D which is located on Bitbucket. D is a sub repository in C. C is a sub repository in A and B. A and B run fine on Travis CI. C however fails. See the output below when Travis CI runs C.
.travis.yml specifies build on branch master for all repositories.
I'm not sure what else to try here. It looks like a simple (and I hope it is) SSH authorization denied, but I've verified the public key on Bitbucket as well as the private key on Travis and it matches the keys of A and B (that are running just fine).
What is the problem here?
Using worker: worker-mac-1.saucelabs.travis-ci.com:travis-mac_osx-19
Installing an SSH key from: repository settings
Key fingerprint: <fingerprint>
$ git clone --depth=50 --branch=master git#github.com:path/to/repo/D.git path/to/repo/D
Cloning into 'path/to/repo/D'...
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
remote: Counting objects: 2005, done.
remote: Compressing objects: 100% (1317/1317), done.
remote: Total 2005 (delta 555), reused 1587 (delta 486)
Receiving objects: 100% (2005/2005), 12.95 MiB | 4.64 MiB/s, done.
Resolving deltas: 100% (555/555), done.
Checking connectivity... done.
$ cd path/to/repo/C
$ git checkout -qf <SHA-1>
$ git submodule init
Submodule 'path/to/repo/D' (git#bitbucket.org:path/to/repo/D.git) registered for path 'path/to/repo/D'
$ git submodule update
Cloning into 'path/to/repo/D'...
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Clone of 'git#bitbucket.org:path/to/repo/D.git' into submodule path 'path/to/repo/D' failed
It's likely that the host key required for BitBucket isn't available on our build machine, hence the failing host verification.
We can investigate that, but I'd recommend in the meantime to put the required dependency on GitHub to fix this issue, if that's possible.

How to switch repositories from one to the next

I was using a github repository from a previous developer.
I am the only coder on this project, so I forked the project over to my own github repository.
Now I would like to commit soley to my repo.
Unfortunately, I realized that I never changed my .git/config , so I was still committing to the old repo. I just changed it to the appropriate url, and when I type :
$> git status
It returns :
=> Working directory clean.
But I know its not because I have several commits I've made. So my local box has different code then what it is pointed to on my repository.
My question is this. Obviously I'm halfway through the process of doing this. Do I need to re-fork to update, and then I'm good. Or is there a special command I need to run to let my local box know its 'git status' command is targeting a new repo to compare itself to? Equally, am I missing something else very important :D ?
Thank you everyone.
You can use git remote to manage your remote
rename origin
git remote rename origin old_origin
add a new origin
git remote add origin git://github.com/my/forked/repo.git
git fetch origin # will create all the remote branches references
# in your local repo
You can also easily setup a new upstream for your current master branch (git 1.7 and more):
git branch --set-upstream master origin/master
The "nothing to commit (working directory clean)" message of git status won't prevent you to push.
After changing the origin, you should see:
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by xxx commits.
#
nothing to commit (working directory clean)
That means you have some commits to push to your new origin.
Note: "git remote"(man) rename failed to rename a remote without fetch refspec, which has been corrected with Git 2.39 (Q4 2022).
See commit 5a97b38 (22 Sep 2022) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 20a5dd6, 10 Oct 2022)
remote: handle rename of remote without fetch refspec
Reported-by: John A. Leuenhagen
Signed-off-by: Jeff King
We return an error when trying to rename a remote that has no fetch refspec:
$ git config --unset-all remote.origin.fetch
$ git remote rename origin foo
fatal: could not unset 'remote.foo.fetch'
To make things even more confusing, we actually do complete the config modification, via git_config_rename_section().
After that we try to rewrite the fetch refspec (to say refs/remotes/foo instead of origin).
But our call to git_config_set_multivar() to remove the existing entries fails, since there aren't any, and it calls die().
We could fix this by using the "gently" form of the config call, and checking the error code.
But there is an even simpler fix: if we know that there are no refspecs to rewrite, then we can skip that part entirely.
git status only shows you the status of your working directory, not the entire repository. It seems like you only need to change the remotes that git push and git pull use by default. Open up .git/config and find your branch.<branch> entries and change them, as well as your remote.<remote> entries. For example, your master entry may look like this:
[branch "master"]
remote = origin
merge = refs/heads/master
Just change remote to reference your (forked) remote.
Also, your remote entry may look like the following:
[remote "myremote"]
url = git://github.com/me/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
You can add a push entry so that your master branch is pushed by default:
[remote "myremote"]
url = git://github.com/me/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
push = master
In whole, but I should include it in this answer. Is that before hand I manually altered my .git/config to include my new repository url. That's why I didn't have to rename or add any origin as Von suggested.
Then I just guessed this and performed
$> git fetch origin
Which returned
From git#github.com:gotoAndBliss/hq_channel
17326ca..043d395 master -> origin/master
* [new branch] panda_streaming -> origin/panda_streaming
+ 6ec9bf8...becbcc6 testing -> origin/testing (forced update)
Then on git status I got
# On branch testing
# Your branch is ahead of 'origin/testing' by 9 commits.
I git pushed origin testing, and I think I'm on target now.

Resources